<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="UTF-8">
	<th:block th:include="include :: header('药品库信息')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>

<body><div class="main-content">


				<div class="row">
					<div class="col-sm-12 search-collapse">
						<div class="query-condition-container">
							<h4 class="query-condition-title">查询条件</h4>
							<div class="query-buttons">
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</div>
						</div>
						<form id="tag-form" class="customize-search-form">
							<div class="customize-form-group-container">
								<div class="customize-form-group">
									<label>药品:</label>
									<input type="text" class="styled-input" placeholder="请输入MDM编码或药品商品名/通用名" name="query" style="width: 350px;"/>
								</div>

								<div class="customize-form-group">
									<label>厂家简称:</label>
									<input type="text" class="styled-input" placeholder="请输入厂家简称" name="manufacturerShortName" style="width: 350px;"/>
								</div>
							</div>
						</form>
					</div>

				</div>
				<div class="row">
					<div class="col-sm-12 select-table table-striped">
						<table id="bootstrap-table"></table>
					</div>
				</div>
</div>

<th:block th:include="include :: footer" />
<script th:inline="javascript">
	var viewFlag = [[${@permission.hasPermi('dtp:configInfo:list')}]];
	var prefix = ctx + "yppz/drugConfig";

	$(function() {
		var panehHidden = false;
		if ($(this).width() < 1590) {
			panehHidden = true;
		}
		//$('body').layout({ initClosed: panehHidden, west__size: 185, resizeWithWindow: false });
		// 回到顶部绑定
		// if ($.fn.toTop !== undefined) {
		// 	var opt = {
		// 		win:$('.ui-layout-center'),
		// 		doc:$('.ui-layout-center')
		// 	};
		// 	$('#scroll-up').toTop(opt);
		// }
		queryUserList();
	});

	function queryUserList() {
		var options = {
			url: prefix + "/getAllProductInfo",
			viewUrl: prefix + "/view/{id}",
			exportUrl: prefix + "/export",
			//sortName: "createTime",
			//sortOrder: "desc",
			modalName: "患者管理品",
			showFooter:true,  //是否显示表格底部区域。
			clickToSelect: true, //是否启用点击行时选中整行的功能。
			singleSelect: true, //是否仅允许选择一行
			fixedColumns: true,
			//fixedNumber: 3,
			//fixedRightNumber: 1,
			columns: [
				{
					checkbox: true
				},
				{ field: "dosage_max", title: "最大剂量数量",visible: false },
				{ field: "unit_max", title: "最大剂量单位",visible: false },
				{ field: "dosage_min", title: "最小剂量数量" ,visible: false},
				{ field: "unit_min", title: "最小剂量单位" ,visible: false},
				{ field: "dosage_normal", title: "常见计量数量",visible: false },
				{ field: "unit_normal", title: "常见计量单位",visible: false },
				{ field: "packing_value", title: "包装单位值",visible: false },
				{ field: "packing_unit", title: "包装单位",visible: false },
				{
					field: "id",
					title: "编号",
					align: 'center',
					visible: false
				},
				{
					field: "product_code",
					title: "商品编码",
					align: 'center'
				},
				{
					field: "product_name",
					title: "商品名称",
					align: 'center'
				},
				{
					field: "mnemonic_code",
					title: "商品名称助记码",
					align: 'center',
					visible: false
				},
				{
					field: "product_description",
					title: "商品描述",
					align: 'center',
					visible: false
				},
				{
					field: "generic_name",
					title: "通用名",
					align: 'center'
				},
				{
					field: "generic_mnemonic_code",
					title: "通用名助记码",
					align: 'center',
					visible: false
				},
				{
					field: "generic_previous_names",
					title: "通用名曾用名",
					align: 'center',
					visible: false
				},
				{
					field: "base_unit",
					title: "基本计量单位",
					align: 'center',
					visible: false
				},
				{
					field: "trademark",
					title: "商标",
					align: 'center',
					visible: false
				},
				{
					field: "packaging",
					title: "包装",
					align: 'center'
				},
				{
					field: "specification",
					title: "规格",
					align: 'center'
				},
				{
					field: "international_barcode",
					title: "国际条形码 (EAN-13)",
					align: 'center',
					visible: false
				},
				{
					field: "manufacturer",
					title: "生产厂家",
					align: 'center'
				},
				{
					field: "entrusted_manufacturer",
					title: "委托厂家",
					align: 'center',
					visible: false
				},
				{
					field: "manufacturer_abbreviation",
					title: "厂家缩写",
					align: 'center',
					visible: true
				},
				{
					field: "origin",
					title: "产地",
					align: 'center',
					visible: false
				},
				{
					field: "category_maj",
					title: "商品大类",
					align: 'center',
					visible: false
				},
				{
					field: "category_min",
					title: "商品子类",
					align: 'center',
					visible: false
				},
				{
					field: "product_type",
					title: "商品类型",
					align: 'center',
					visible: false
				},
				{
					field: "product_status",
					title: "商品状态",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						switch (value) {
							case '启用':
								return '启用';
							case '停用':
								return '停用';
							default:
								return '-';
						}
					}
				},
				{
					field: "purchase_tax_rate",
					title: "进项税率",
					align: 'center',
					visible: false
				},
				{
					field: "sales_tax_rate",
					title: "销项税率",
					align: 'center',
					visible: false
				},
				{
					field: "import_export_status",
					title: "进口/国产商品",
					align: 'center',
					visible: false
				},
				{
					field: "major_category",
					title: "大类",
					align: 'center',
					visible: false
				},
				{
					field: "medium_category",
					title: "中类",
					align: 'center',
					visible: false
				},
				{
					field: "minor_category",
					title: "小类",
					align: 'center',
					visible: false
				},
				{
					field: "sub_category",
					title: "子类",
					align: 'center',
					visible: false
				},
				{
					field: "ingredients",
					title: "成分",
					align: 'center',
					visible: false
				},
				{
					field: "dtp_flag",
					title: "DTP商品",
					align: 'center',
					visible: false
				},
				{
					field: "daily_standard_consumption",
					title: "日标准消耗量",
					align: 'center',
					visible: false
				},
				{
					field: "duplicate_suspected",
					title: "疑似重复",
					align: 'center',
					visible: false
				},
				{
					field: "alternative_code",
					title: "替代编码",
					align: 'center',
					visible: false
				},
				{
					field: "marketing_authorization_holder",
					title: "上市许可持有人/注册人/备案人",
					align: 'center',
					visible: false
				},
				{
					field: "medication_days",
					title: "用药天数",
					align: 'center',
					visible: false
				},
				{
					field: "small_code_southchina_specific",
					title: "小码华南专用",
					align: 'center',
					visible: false
				},
				{
					field: "corresponding_major_code",
					title: "对应大码",
					align: 'center',
					visible: false
				},
				{
					field: "conversion_ratio_to_alternative",
					title: "与替代编码转换比",
					align: 'center',
					visible: false
				},
				{
					field: "disease_type",
					title: "疾病种",
					align: 'center',
					visible: false
				},
				{
					field: "brand_manufacturer_name",
					title: "品牌厂家名称",
					align: 'center',
					visible: false
				},
				{
					field: "group_name",
					title: "集团名称",
					align: 'center',
					visible: false
				},
				{
					field: "external_organization",
					title: "外部组织机构",
					align: 'center',
					visible: false
				},
				{
					field: "national_negotiated_product",
					title: "国谈品种",
					align: 'center',
					visible: false
				},
				{
					field: "national_standard_code",
					title: "国家贯标码",
					align: 'center',
					visible: false
				},
				{
					field: "national_standard_code_2",
					title: "国家贯标码2",
					align: 'center',
					visible: false
				},
				{
					field: "medical_insurance_min_dose_unit",
					title: "医保最小剂量单位",
					align: 'center',
					visible: false
				},
				{
					field: "medical_market_status",
					title: "医保市场状态",
					align: 'center',
					visible: false
				},
				{
					field: "accounting_manufacturer",
					title: "核算厂家",
					align: 'center',
					visible: false
				},
				{
					field: "department_affiliation",
					title: "部门归属",
					align: 'center',
					visible: false
				},
				{
					field: "chronic_disease_first_line_treatment",
					title: "慢病一线治疗用药",
					align: 'center',
					visible: false
				},
				{
					field: "is_medical_generic_name",
					title: "是否医保通用名",
					align: 'center',
					visible: false
				},
				{
					field: "covid_tag",
					title: "新冠商品标签",
					align: 'center',
					visible: false
				},
				{
					field: "product_remarks",
					title: "备注",
					align: 'center',
					visible: false
				}, {
					"field": "is_insurance_drug",
					"title": "是否医保药品",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				},
				{
					"field": "insurance_category",
					"title": "医保类别",
					align: 'center',
					visible: false
				},
				{
					"field": "purchase_limit_quantity",
					"title": "限购数量",
					align: 'center',
					visible: false
				},
				{
					"field": "prescription_required",
					"title": "是否凭处方销售",
					align: 'center',
					visible: false,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				},
				{
					"field": "prohibit_ordering",
					"title": "禁止请货",
					align: 'center',
					visible: false,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				},
				{
					"field": "mid_pack_order_logic",
					"title": "中包装请货逻辑",
					align: 'center',
					visible: false
				},
				{
					"field": "max_order_limit",
					"title": "请货最大上限",
					align: 'center',
					visible: false
				},
				{
					"field": "drug_delivery_way",
					"title": "给药方式",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						// Assuming drug_delivery_way is an integer representing different administration methods.
						// You should replace the following switch-case with actual mappings if available.
						switch (value) {
							case 1:
								return '口服';
							case 2:
								return '注射';
							case 3:
								return '外用';
							default:
								return '-';
						}
					}
				},
				{
					"field": "registered_item",
					"title": "是否登记管理品",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				},
				{
					"field": "follow_up_item",
					"title": "是否随访管理品",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				},
				{
					"field": "cold_chain_item",
					"title": "是否冷链管理品",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				},
				{
					"field": "flow_item",
					"title": "企业流向管理方式",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						// Assuming flow_item is an integer representing different flow management types.
						// You should replace the following switch-case with actual mappings if available.
						switch (value) {
							case 1:
								return '类型1';
							case 2:
								return '类型2';
							default:
								return '-';
						}
					}
				},
				{
					"field": "charity_aid_item",
					"title": "是否慈善援助管理品",
					align: 'center',
					visible: true,
					formatter: function(value, row, index) {
						return value === 1 ? '是' : value === 0 ? '否' : '-';
					}
				}
			]
		};
		$.table.init(options);
	}

	/* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
	function resetPre() {
		resetDate();
		$("#tag-form")[0].reset();
		$("#deptId").val("");
		$("#parentId").val("");
		$(".curSelectedNode").removeClass("curSelectedNode");
		$.table.search();
	}
	/* 添加用户-选择用户-提交(子页面调用父页面形式) */
	function submitHandler(index, layero) {
		debugger
		var rows = $.table.selectFirstColumns();

		if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}
		$.modal.close();
		// 父页面的方法
		// activeWindow().selectUsers();
		// 父页面的变量
		activeWindow().$('#userids').html('我是通过方式一来的：' + rows.join());
	}

	/* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
	function getSelections() {
		return $.table.selectFirstColumns();
	}

	function selectTableObject() {
		// 动态选择所有列并映射到更具描述性的名称
		var columnsData = {
			id: $.table.selectColumns('id'),
			product_code: $.table.selectColumns('product_code'),
			product_name: $.table.selectColumns('product_name'),
			generic_name: $.table.selectColumns('generic_name'),
			packaging: $.table.selectColumns('packaging'),
			specification: $.table.selectColumns('specification'),
			manufacturer: $.table.selectColumns('manufacturer'),
			manufacturer_abbreviation: $.table.selectColumns('manufacturer_abbreviation'),
			product_status: $.table.selectColumns('product_status'),
			dtp_flag: $.table.selectColumns('dtp_flag'),
			is_insurance_drug: $.table.selectColumns('is_insurance_drug'),
			drug_delivery_way: $.table.selectColumns('drug_delivery_way'),
			registered_item: $.table.selectColumns('registered_item'),
			follow_up_item: $.table.selectColumns('follow_up_item'),
			cold_chain_item: $.table.selectColumns('cold_chain_item'),
			flow_item: $.table.selectColumns('flow_item'),
			charity_aid_item: $.table.selectColumns('charity_aid_item'),

			dosage_max: $.table.selectColumns('dosage_max'),
			unit_max: $.table.selectColumns('unit_max'),
			dosage_min: $.table.selectColumns('dosage_min'),
			unit_min: $.table.selectColumns('unit_min'),
			dosage_normal: $.table.selectColumns('dosage_normal'),
			unit_normal: $.table.selectColumns('unit_normal'),
			packing_value: $.table.selectColumns('packing_value'),
			packing_unit: $.table.selectColumns('packing_unit'),
		};

		// 构建返回的对象数组
		var selectedRows = [];

		// 假设 $.table.selectColumns 返回的是一个数组，我们检查每个字段是否为空或未定义来判断是否有选择
		for (var i = 0; i < columnsData.id.length; i++) {
			if (columnsData.id[i]) { // 如果 id 存在，则认为该行被选中
				var row = {
					productId: columnsData.id[i],
					productCode: columnsData.product_code[i],
					productName: columnsData.product_name[i],
					genericName: columnsData.generic_name[i],
					specification: columnsData.specification[i],
					packaging: columnsData.packaging[i],
					manufacturer: columnsData.manufacturer[i],
					manufacturerAbbreviation: columnsData.manufacturer_abbreviation[i],
					productStatus: columnsData.product_status[i],
					dtpFlag: columnsData.dtp_flag[i],
					isInsuranceDrug: columnsData.is_insurance_drug[i],
					administrationMethod: columnsData.drug_delivery_way[i],
					registeredItem: columnsData.registered_item[i],
					followUpItem: columnsData.follow_up_item[i],
					coldChainItem: columnsData.cold_chain_item[i],
					flowItem: columnsData.flow_item[i],
					charityAidItem: columnsData.charity_aid_item[i],

					dosageMax: columnsData.dosage_max[i],
					unitMax: columnsData.unit_max[i],
					dosageMin: columnsData.dosage_min[i],
					unitMin: columnsData.unit_min[i],
					dosageNormal: columnsData.dosage_normal[i],
					unitNormal: columnsData.unit_normal[i],
					packingValue: columnsData.packing_value[i],
					packingUnit: columnsData.packing_unit[i],
				};
				selectedRows.push(row);
			}
		}

		return selectedRows;
	}
	/*回调返回所有的选中行数据*/
	function selectColumns2() {
		return $.table.selectColumns2();
	}
	$("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
		var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
		var rowIds = $.table.affectedRowIds(rows);
		$("#rowIds").val(rowIds);
	});
</script>
</body>

</html>
