drugconfigAdd.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('门店积分商品列表新增')" />
  5. <th:block th:include="include :: ztree-css" />
  6. <th:block th:include="include :: select2-css" />
  7. <th:block th:include="include :: bootstrap-select-css" />
  8. </head>
  9. <body class="white-bg">
  10. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  11. <form id="form-SSpglJfspProductinfo-add" class="customize-search-form">
  12. <div class="customize-form-group-container">
  13. <div class="customize-form-group">
  14. <label>药品编码</label>
  15. <select class="styled-input" id="mdmCode" name="mdmCode">
  16. <option value="">--药品编码或药品名--</option>
  17. </select>
  18. </div>
  19. <!-- <div class="customize-form-group">-->
  20. <!-- <label class="is-required">药品编码:</label>-->
  21. <!-- <input name="mdmCode" placeholder="请输入药品编码或药品名称" id="mdmCode" class="styled-input" type="text" required>-->
  22. <!-- <div id="suggestions" class="dropdown-list"></div>-->
  23. <!-- </div>-->
  24. <div class="customize-form-group">
  25. <label>规格:</label>
  26. <input name="specification" placeholder="请输入规格" id="specification" class="styled-input" type="text">
  27. </div>
  28. <div class="customize-form-group">
  29. <label>包装:</label>
  30. <input name="packaging" placeholder="请输入包装" id="packaging" class="styled-input" type="text">
  31. </div>
  32. <div class="customize-form-group">
  33. <label class="is-required">通用名:</label>
  34. <input name="genericName" placeholder="请输入通用名" id="genericName" class="styled-input" type="text" required>
  35. </div>
  36. <div class="customize-form-group">
  37. <label class="is-required">商品名:</label>
  38. <input name="productName" placeholder="请输入商品名" id="productName" class="styled-input" type="text" required>
  39. </div>
  40. <div class="customize-form-group">
  41. <label>厂家简称:</label>
  42. <input name="manufacturerShortName" placeholder="请输入厂家简称" id="manufacturerShortName" class="styled-input" type="text">
  43. </div>
  44. <div class=" panel panel-warning" style="width: 720px">
  45. <div class="panel-heading">
  46. <i class="fa fa-info-circle"></i> 以下是选择项的说明
  47. </div>
  48. <div class="panel-body">
  49. <p>是否随访管品说明</p>
  50. <p>分是否冷链管理品说明</p>
  51. <p>是否登记管理品说明</p>
  52. <p>是否慈善援助管理品说明</p>
  53. </div>
  54. </div>
  55. <div class="customize-form-group">
  56. <label class="is-required">是否随访管理品:</label>
  57. <select name="isFollowUpManaged" id="isFollowUpManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}" required>
  58. <option value="">请选择</option>
  59. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  60. </select>
  61. </div>
  62. <div class="customize-form-group" id="isColdChainManagedDiv">
  63. <label class="is-required">是否冷链管理品:</label>
  64. <select name="isColdChainManaged" id="isColdChainManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}" required>
  65. <option value="">请选择</option>
  66. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  67. </select>
  68. </div>
  69. <div class="customize-form-group" id="isRegisteredManagedDiv">
  70. <label>是否登记管理品:</label>
  71. <select name="isRegisteredManaged" id="isRegisteredManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
  72. <option value="">请选择</option>
  73. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  74. </select>
  75. </div>
  76. <div class="customize-form-group">
  77. <label>是否慈善援助管理品:</label>
  78. <select name="isCharityAidManaged" id="isCharityAidManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
  79. <option value="">请选择</option>
  80. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  81. </select>
  82. </div>
  83. <div class="customize-form-group">
  84. <label class="is-required">给药方式:</label>
  85. <select name="administrationMethod" id="administrationMethod" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_yyff')}" required>
  86. <option value="">请选择</option>
  87. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  88. </select>
  89. </div>
  90. <div class="customize-form-group">
  91. <label>企业流向管理方式:</label>
  92. <select name="enterpriseFlowManagement" id="enterpriseFlowManagement" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yppz_qylxglfs')}">
  93. <option value="">请选择</option>
  94. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  95. </select>
  96. </div>
  97. <div class="customize-form-group">
  98. <label>状态:</label>
  99. <select name="status" id="status" class="styled-input" th:with="type=${@dict.getType('sys_hzgl_qyty_status')}">
  100. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  101. </select>
  102. </div>
  103. </div>
  104. </form>
  105. </div>
  106. <th:block th:include="include :: footer" />
  107. <th:block th:include="include :: ztree-js" />
  108. <th:block th:include="include :: select2-js" />
  109. <th:block th:include="include :: bootstrap-select-js" />
  110. <script type="text/javascript">
  111. var prefix = ctx + "yppz/drugConfig";
  112. var isRegisteredManaged;
  113. var dtp_flag;
  114. function submitHandler() {
  115. if ($.validate.form()) {
  116. add();
  117. }
  118. }
  119. function add() {
  120. var data = $("#form-SSpglJfspProductinfo-add").serializeArray();
  121. $.ajax({
  122. cache : true,
  123. type : "POST",
  124. url : ctx + "yppz/drugConfig/savedrugConfig",
  125. data : data,
  126. async : false,
  127. error : function(request) {
  128. $.modal.alertError("失败");
  129. },
  130. success : function(data) {
  131. $.operate.successCallback(data);
  132. }
  133. });
  134. }
  135. // $(document).ready(function() {
  136. // let timeout;
  137. //
  138. // // 监听 dValueKey 输入框的 input 事件
  139. // $('#mdmCode').on('input', function() {
  140. //
  141. // clearTimeout(timeout);
  142. // var query = $('#mdmCode').val().trim();
  143. // console.log("query===="+query);
  144. // // 如果输入为空,清空 dValueId 输入框并停止进一步操作
  145. // if (!query) {
  146. // $('#mdmCode').val('');
  147. // $('#genericName').val('');
  148. // $('#productName').val('');
  149. // $('#manufacturerShortName').val('');
  150. // $('#packaging').val('');
  151. // $('#specification').val('');
  152. //
  153. // $('#isFollowUpManaged').val('');
  154. // $('#isColdChainManaged').val('');
  155. // $('#isRegisteredManaged').val('');
  156. // $('#isCharityAidManaged').val('');
  157. //
  158. // updateButtonVisibility1(); // 更新按钮可见性
  159. // return;
  160. // }
  161. //
  162. // // 使用防抖机制延迟发送请求
  163. // timeout = setTimeout(() => {
  164. // // 发送 AJAX 请求到服务器查询数据
  165. // hzparam={query:query};//模拟微信扫码获取微信openId
  166. // console.log("hzparam===="+hzparam);
  167. // // 清空表格中的所有数据行
  168. // // $('#drugInfoTable tbody').empty();
  169. // $.ajax({
  170. // cache: true,
  171. // type: "POST",
  172. // url: prefix+'/searchDrugs', // 替换为实际的搜索 URL
  173. // data: hzparam,
  174. // async: false,
  175. // success: function (data) {
  176. // console.log("data===="+data);
  177. // if(data.code==0){
  178. // $('#mdmCode').val(data.data.product_code);
  179. // $('#genericName').val(data.data.generic_name);
  180. // $('#productName').val(data.data.product_name);
  181. // $('#manufacturerShortName').val(data.data.manufacturer_abbreviation);
  182. // $('#packaging').val(data.data.packaging);
  183. // $('#specification').val(data.data.specification);
  184. //
  185. // $('#isFollowUpManaged').val(data.data.follow_up_item);
  186. // $('#isColdChainManaged').val(data.data.cold_chain_item);
  187. // $('#isRegisteredManaged').val(data.data.registered_item);
  188. // $('#isCharityAidManaged').val(data.data.charity_aid_item);
  189. //
  190. //
  191. // //$('#dtp_flag').val(data.data.dtp_flag);
  192. // dtp_flag=data.data.dtp_flag;
  193. // updateButtonVisibility1(); // 更新按钮可见性
  194. // if(dtp_flag==="D"){
  195. // isRegisteredManaged =1;
  196. // $('#isRegisteredManaged').val(isRegisteredManaged);
  197. // }
  198. //
  199. // }else{
  200. // // 清空表格中的所有数据行
  201. // // $('#drugInfoTable tbody').empty();
  202. // // 如果没有找到匹配的数据,清空 dValueId 输入框
  203. // $('#mdmCode').val('');
  204. // $('#genericName').val('');
  205. // $('#productName').val('');
  206. // $('#manufacturerShortName').val('');
  207. // $('#packaging').val('');
  208. // $('#specification').val('');
  209. //
  210. // $('#isFollowUpManaged').val('');
  211. // $('#isColdChainManaged').val('');
  212. // $('#isRegisteredManaged').val('');
  213. // $('#isCharityAidManaged').val('');
  214. //
  215. // updateButtonVisibility1(); // 更新按钮可见性
  216. // }
  217. // },
  218. // error: function(error) {
  219. // // 清空 dValueId 输入框
  220. // $('#mdmCode').val('');
  221. // $('#genericName').val('');
  222. // $('#productName').val('');
  223. // $('#manufacturerShortName').val('');
  224. // $('#packaging').val('');
  225. // $('#specification').val('');
  226. //
  227. // $('#isFollowUpManaged').val('');
  228. // $('#isColdChainManaged').val('');
  229. // $('#isRegisteredManaged').val('');
  230. // $('#isCharityAidManaged').val('');
  231. //
  232. // }
  233. // });
  234. //
  235. // }, 1300); // 300ms 的延迟
  236. // });
  237. // // 页面加载时检查 dValueIdInput 的初始状态
  238. // updateButtonVisibility1();
  239. // });
  240. $(document).ready(function() {
  241. // 初始化 Select2
  242. $('#mdmCode').select2({
  243. placeholder: '--药品编码或药品名--',
  244. allowClear: true,
  245. ajax: {
  246. url: prefix + '/searchDrugs', // 替换为实际的搜索 URL
  247. dataType: 'json',
  248. delay: 300,
  249. method: 'POST', // 使用 POST 方法
  250. data: function (params) {
  251. return {
  252. query: params.term // search term
  253. };
  254. },
  255. processResults: function (data) {
  256. if (data.code == 0) {
  257. return {
  258. results: data.data.map(function(item) {
  259. return { id: item.product_code, text: item.product_code + ' - ' + item.product_name, product_code: item.product_code };
  260. })
  261. };
  262. } else {
  263. return { results: [] };
  264. }
  265. },
  266. cache: true
  267. }
  268. });
  269. // 处理选择事件
  270. $('#mdmCode').on('select2:select', function (e) {
  271. var selectedData = e.params.data;
  272. var selectedProductCode = selectedData.product_code;
  273. console.log("Selected Product Code:", selectedProductCode);
  274. // 再次发送 AJAX 请求以获取详细信息
  275. hzparam = { query: selectedProductCode };
  276. $.ajax({
  277. cache: true,
  278. type: "POST",
  279. url: prefix + '/searchDrugsObject', // 替换为实际的获取详情 URL
  280. data: hzparam,
  281. async: false,
  282. success: function(data) {
  283. console.log("details====" + JSON.stringify(data));
  284. if (data.code == 0) {
  285. populateFormFields(data.data);
  286. } else {
  287. clearFormFields();
  288. }
  289. },
  290. error: function(error) {
  291. clearFormFields();
  292. }
  293. });
  294. });
  295. // 清空表单字段
  296. function clearFormFields() {
  297. $('#mdmCode').val('').trigger('change');
  298. $('#genericName').val('');
  299. $('#productName').val('');
  300. $('#manufacturerShortName').val('');
  301. $('#packaging').val('');
  302. $('#specification').val('');
  303. $('#isFollowUpManaged').val('');
  304. $('#isColdChainManaged').val('');
  305. $('#isRegisteredManaged').val('');
  306. $('#isCharityAidManaged').val('');
  307. }
  308. // 填充表单字段
  309. function populateFormFields(data) {
  310. $('#mdmCode').val(data.product_code);//.trigger('change')
  311. $('#genericName').val(data.generic_name);
  312. $('#productName').val(data.product_name);
  313. $('#manufacturerShortName').val(data.manufacturer_abbreviation);
  314. $('#packaging').val(data.packaging);
  315. $('#specification').val(data.specification);
  316. $('#isFollowUpManaged').val(data.follow_up_item);
  317. $('#isColdChainManaged').val(data.cold_chain_item);
  318. $('#isRegisteredManaged').val(data.registered_item);
  319. $('#isCharityAidManaged').val(data.charity_aid_item);
  320. dtp_flag = data.dtp_flag;
  321. // updateButtonVisibility1(); // 更新按钮可见性
  322. if (dtp_flag === "D") {
  323. isRegisteredManaged = 1;
  324. $('#isRegisteredManaged').val(isRegisteredManaged);
  325. }
  326. }
  327. // 页面加载时检查初始状态
  328. updateButtonVisibility1();
  329. });
  330. function updateButtonVisibility1() {
  331. var dValueId = $('#mdmCode').val().trim();
  332. if (dtp_flag==="D") {
  333. $('#isRegisteredManagedDiv').hide();
  334. } else {
  335. $('#isRegisteredManagedDiv').show();
  336. }
  337. }
  338. </script>
  339. <style>
  340. .styled-input {
  341. padding: 5px;
  342. width: 200px;
  343. position: relative;
  344. }
  345. .dropdown-list {
  346. position: absolute;
  347. border: 1px solid #ccc;
  348. background-color: white;
  349. z-index: 1000;
  350. max-height: 150px;
  351. overflow-y: auto;
  352. width: 100%;
  353. box-sizing: border-box;
  354. }
  355. .dropdown-item {
  356. padding: 5px;
  357. cursor: pointer;
  358. }
  359. .dropdown-item:hover {
  360. background-color: #f0f0f0;
  361. }
  362. </style>
  363. </body>
  364. </html>