form.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <view class="form">
  3. <view class="DrawerPage" :class="modalName=='DrawerModalL'?'show':''">
  4. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  5. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png"
  6. :isBack="true">
  7. <block slot="content">胶体金检测</block>
  8. </cu-custom>
  9. <view>
  10. <view>
  11. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  12. <view class="action">
  13. <text class="cuIcon-titles text-green"></text>
  14. <text>产品信息</text>
  15. </view>
  16. </view>
  17. <view class="cu-form-group">
  18. <view class="title">所属区域</view>
  19. <picker mode="multiSelector" :range="regionArray" @change="RegionChange"
  20. :value="regionIndex"
  21. @columnchange="columnchange">
  22. <view class="picker">
  23. {{ queryXzq }}
  24. </view>
  25. </picker>
  26. </view>
  27. <view class="cu-form-group" @tap="showModal"
  28. :data-target="'DrawerModalL'">
  29. <view class="title">单位名称</view>
  30. <picker disabled="disabled">
  31. <view class="picker">
  32. {{ companyDetailInfo.bySampleUnitName || "请选择单位" }}
  33. </view>
  34. </picker>
  35. </view>
  36. <view class="cu-form-group" @tap="showModal"
  37. :data-target="'SampleModelL'">
  38. <view class="title">样品名称</view>
  39. <picker disabled="disabled">
  40. <view class="picker">
  41. {{ sampleDetailInfo.productName || "请选择样品" }}
  42. </view>
  43. </picker>
  44. </view>
  45. <view class="cu-form-group" @tap="showModal"
  46. :data-target="'JTJModelL'">
  47. <view class="title">胶体金类型</view>
  48. <picker disabled="disabled">
  49. <view class="picker">
  50. {{ JTJDetailInfo.name || "请选择胶体金类型" }}
  51. </view>
  52. </picker>
  53. </view>
  54. <view class="padding flex flex-direction padding-bottom-xl fixedFootBtn bg-white padding-top-xs">
  55. <button class="cu-btn bg-green lg margin-top-sm shadow-blur" type="" @tap="nextSetp">
  56. 上报
  57. </button>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="DrawerClose" :class="modalName==='DrawerModalL'?'show':''" @tap="hideModal">
  63. <text class="cuIcon-pullright"></text>
  64. </view>
  65. <scroll-view scroll-y class="DrawerWindow solid-right" :class="modalName==='DrawerModalL'?'show':''">
  66. <view class="bg-white padding-bottom" style="min-height: 100vh">
  67. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  68. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png">
  69. <block slot="content">企业列表</block>
  70. </cu-custom>
  71. <view class="cu-list menu text-left">
  72. <view class="cu-bar search bg-white">
  73. <view class="search-form round">
  74. <text class="cuIcon-search"></text>
  75. <input type="text" placeholder="输入企业名称搜索" confirm-type="search" v-model="enterprisesName" />
  76. </view>
  77. <view class="action">
  78. <button class="cu-btn bg-green shadow-blur round" @tap="searchEnterPrise">搜索</button>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="cu-list menu bg-white margin-top-sm" v-for="(item,index) in qyList" :key="item.qydm"
  83. @tap="choseQy(index)">
  84. <view class="cu-item">
  85. <view class="action">
  86. <text class="cuIcon-titles text-green"></text>
  87. {{ item.enterprisesName }}
  88. </view>
  89. </view>
  90. <view class="cu-item">
  91. 所属区域:<!-- {{ item.enterprisesAddress.split(" ")[0].replaceAll(",", "-") }} -->
  92. </view>
  93. </view>
  94. <view class="cu-load bg-green light text-sm" v-show="pageTotal !==0" @tap="getEnterPriseList"
  95. :class="pageNum > pageTotal?'over':'more'"></view>
  96. <view class="radius shadow-warp bg-white margin-top text-lg" v-show="pageTotal === 0">
  97. <view class="cu-list menu-avatar">
  98. <view class="cu-item">
  99. <view class="content">
  100. <view class="text-sm text-center" style="justify-content: center;">
  101. <text class="text-cut text-lg">
  102. <text class="cuIcon-warn text-yellow margin-right-xs text-xl"></text>
  103. 未查询到相关数据
  104. </text>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </scroll-view>
  112. <view class="DrawerClose" :class="modalName==='SampleModelL'?'show':''" @tap="hideModal">
  113. <text class="cuIcon-pullright"></text>
  114. </view>
  115. <scroll-view scroll-y class="DrawerWindow solid-right" :class="modalName==='SampleModelL'?'show':''">
  116. <view class="bg-white padding-bottom" style="min-height: 100vh">
  117. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  118. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png">
  119. <block slot="content">样品列表</block>
  120. </cu-custom>
  121. <view class="cu-list menu bg-white margin-top-sm" v-for="(item,index) in sampleList" :key="item.qydm"
  122. @tap="choseSample(index)">
  123. <view class="cu-item">
  124. <view class="action">
  125. <text class="cuIcon-titles text-green"></text>
  126. {{ item.productName }}
  127. </view>
  128. </view>
  129. </view>
  130. <view class="cu-load bg-green light text-sm" v-show="spageTotal !==0" @tap="getSampleList"
  131. :class="spageNum > spageTotal?'over':'more'"></view>
  132. <view class="radius shadow-warp bg-white margin-top text-lg" v-show="spageTotal === 0">
  133. <view class="cu-list menu-avatar">
  134. <view class="cu-item">
  135. <view class="content">
  136. <view class="text-sm text-center" style="justify-content: center;">
  137. <text class="text-cut text-lg">
  138. <text class="cuIcon-warn text-yellow margin-right-xs text-xl"></text>
  139. 未查询到相关数据
  140. </text>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. </scroll-view>
  148. <view class="DrawerClose" :class="modalName==='JTJModelL'?'show':''" @tap="hideModal">
  149. <text class="cuIcon-pullright"></text>
  150. </view>
  151. <scroll-view scroll-y class="DrawerWindow solid-right" :class="modalName==='JTJModelL'?'show':''">
  152. <view class="bg-white padding-bottom" style="min-height: 100vh">
  153. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  154. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png">
  155. <block slot="content">胶体金类型</block>
  156. </cu-custom>
  157. <view class="cu-list menu text-left">
  158. <view class="cu-bar search bg-white">
  159. <view class="search-form round">
  160. <text class="cuIcon-search"></text>
  161. <input type="text" placeholder="输入胶体金类型搜索" confirm-type="search" v-model="JTJName" />
  162. </view>
  163. <view class="action">
  164. <button class="cu-btn bg-green shadow-blur round" @tap="searchJTJ">搜索</button>
  165. </view>
  166. </view>
  167. </view>
  168. <view class="cu-list menu bg-white margin-top-sm" v-for="(item,index) in JTJList" :key="item.qydm"
  169. @tap="choseJTJ(index)">
  170. <view class="cu-item">
  171. <view class="action">
  172. <text class="cuIcon-titles text-green"></text>
  173. {{ item.name }}
  174. </view>
  175. </view>
  176. </view>
  177. <view class="cu-load bg-green light text-sm" v-show="jpageTotal !==0" @tap="getJTJList"
  178. :class="jpageNum > jpageTotal?'over':'more'"></view>
  179. <view class="radius shadow-warp bg-white margin-top text-lg" v-show="jpageTotal === 0">
  180. <view class="cu-list menu-avatar">
  181. <view class="cu-item">
  182. <view class="content">
  183. <view class="text-sm text-center" style="justify-content: center;">
  184. <text class="text-cut text-lg">
  185. <text class="cuIcon-warn text-yellow margin-right-xs text-xl"></text>
  186. 未查询到相关数据
  187. </text>
  188. </view>
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. </view>
  194. </scroll-view>
  195. </view>
  196. </template>
  197. <script>
  198. import { _sampleDetail } from "../sample-detail/sample-detail-model.js";
  199. export default {
  200. data() {
  201. return {
  202. regionArray: [],
  203. regionIndex: [],
  204. queryXzq: "请选择",
  205. xzqObjList: [],
  206. qyList: [],
  207. companyDetailInfo: {},
  208. modalName: null,
  209. enterprisesName: null,
  210. pageNum: 1,
  211. pageSize: 10,
  212. pageTotal: 1,
  213. sampleName: '',
  214. sampleList: [],
  215. spageNum: 1,
  216. spageSize: 10,
  217. spageTotal: 1,
  218. sampleDetailInfo: {},
  219. JTJName: '',
  220. JTJList: [],
  221. jpageNum: 1,
  222. jpageSize: 100,
  223. jpageTotal: 1,
  224. JTJDetailInfo: {},
  225. }
  226. },
  227. mounted() {
  228. this.initRange();
  229. },
  230. methods: {
  231. nextSetp() {
  232. if(!this.queryXzqdm) {
  233. this.$msg("请先选择所属区域");
  234. return false;
  235. }
  236. if(!this.companyDetailInfo.qydm) {
  237. this.$msg("请先选择单位");
  238. return false;
  239. }
  240. if(!this.sampleDetailInfo.productName) {
  241. this.$msg("请先选择样品");
  242. return false;
  243. }
  244. if(!this.JTJDetailInfo.name) {
  245. this.$msg("请先选择胶体金类型");
  246. return false;
  247. }
  248. uni.navigateTo({
  249. url: "/pages/quick-task/index"
  250. });
  251. },
  252. async initRange() {
  253. const { unitId,name } = uni.getStorageSync("userInfo");
  254. let role = uni.getStorageSync("role");
  255. let xzqdm;
  256. if(role=="f35551e4a06647dea5c2c43aaba22c2a"){
  257. xzqdm = unitId.substring(4, 13);
  258. }
  259. if(role=="a1cbf841b0514b47bbdd3f50c80b729f"){
  260. xzqdm = unitId
  261. }
  262. let level = 0;
  263. if (xzqdm.endsWith("0000000")) { //省
  264. level = 3;
  265. } else if (xzqdm.endsWith("00000")) { //市
  266. level = 2;
  267. } else if (xzqdm.endsWith("000")) { //县
  268. level = 1;
  269. }
  270. const xzqlist = await this.getSubXzqList(xzqdm);
  271. if(level!==0){
  272. xzqlist.unshift({
  273. xzqdm: "",
  274. xzqmc: "请选择"
  275. });
  276. this.regionArray.splice(0, this.regionArray.length, xzqlist.map(v => v.xzqmc));
  277. this.xzqObjList.splice(0, this.xzqObjList.length, xzqlist);
  278. this.regionIndex.splice(0, this.regionIndex.length, 0);
  279. for (let i = 0; i < level - 1; i++) {
  280. this.regionArray.push(["请选择"]);
  281. this.xzqObjList.push({ xzqdm: "", xzqmc: "请选择" });
  282. this.regionIndex.push(0);
  283. }
  284. }else{
  285. xzqlist.unshift({
  286. xzqdm: unitId,
  287. xzqmc: name
  288. });
  289. this.regionArray.push([name]);
  290. this.xzqObjList.push({ xzqdm: unitId, xzqmc: name });
  291. this.regionIndex.push(0);
  292. }
  293. },
  294. getSubXzqList(xzqdm) {
  295. return new Promise(resolve => {
  296. _sampleDetail.getSubXzqList(xzqdm, res => {
  297. resolve(res);
  298. });
  299. });
  300. },
  301. RegionChange(e) {
  302. this.regionIndex = e.detail.value;
  303. let xzqdm = "", xzqmc = [];
  304. for (let i = 0; i <= this.regionIndex.length - 1; i++) {
  305. if (this.regionArray[i][this.regionIndex[i]] !== "请选择") {
  306. xzqmc.push(this.regionArray[i][this.regionIndex[i]]);
  307. xzqdm = this.xzqObjList[i][this.regionIndex[i]].xzqdm;
  308. }
  309. }
  310. this.queryXzqdm = xzqdm;
  311. this.queryXzq = xzqmc.join("/");
  312. },
  313. async columnchange(e) {
  314. const { column, value } = e.detail;
  315. const xzqdm = this.xzqObjList[column][value]["xzqdm"];
  316. if (xzqdm) {
  317. if (column <= this.regionIndex.length - 2) {
  318. const subList = await this.getSubXzqList(xzqdm);
  319. subList.unshift({
  320. xzqdm: "",
  321. xzqmc: "请选择"
  322. });
  323. this.xzqObjList.splice(column + 1, 1, subList); //逐级push-乡镇
  324. this.regionIndex.splice(column + 1, 1, 0);
  325. this.regionArray.splice(column + 1, 1, subList.map(v => v.xzqmc));
  326. for (let i = column + 2; i < this.regionIndex.length; i++) {
  327. this.xzqObjList.splice(i, 1, [{ xzqdm: "", xzqmc: "请选择" }]); //逐级push-乡镇
  328. this.regionIndex.splice(i, 1, 0);
  329. this.regionArray.splice(i, 1, ["请选择"]);
  330. }
  331. }
  332. } else {
  333. for (let i = column + 1; i < this.regionIndex.length; i++) {
  334. this.xzqObjList.splice(i, 1, [{ xzqdm: "", xzqmc: "请选择" }]); //逐级push-乡镇
  335. this.regionIndex.splice(i, 1, 0);
  336. this.regionArray.splice(i, 1, ["请选择"]);
  337. }
  338. }
  339. },
  340. showModal(e) {
  341. const modalName = e.currentTarget.dataset.target;
  342. if (modalName === "DrawerModalL") {
  343. if(!this.queryXzqdm) {
  344. this.$msg("请先选择所属区域");
  345. return false;
  346. }
  347. this.getEnterPriseList();
  348. } else if (modalName === "SampleModelL") {
  349. if(!this.companyDetailInfo.qydm) {
  350. this.$msg("请先选择单位");
  351. return false;
  352. }
  353. this.getSampleList()
  354. console.log(this.sampleList)
  355. } else if (modalName === "JTJModelL") {
  356. this.getJTJTypeList()
  357. }
  358. this.modalName = modalName;
  359. },
  360. choseQy(index) {
  361. const {
  362. enterprisesName: bySampleUnitName,
  363. qydm,
  364. } = this.qyList[index];
  365. this.companyDetailInfo.bySampleUnitName = bySampleUnitName;
  366. this.companyDetailInfo.qydm = qydm;
  367. this.modalName = null;
  368. uni.setStorageSync("enterprisesInfo", {
  369. enterprisesName: bySampleUnitName,
  370. qydm
  371. });
  372. },
  373. choseSample(index) {
  374. this.sampleDetailInfo = {
  375. ...this.sampleList[index]
  376. }
  377. this.modalName = null;
  378. uni.setStorageSync("sampleInfo", this.sampleDetailInfo);
  379. },
  380. choseJTJ(index) {
  381. this.JTJDetailInfo = {
  382. ...this.JTJList[index]
  383. }
  384. this.modalName = null;
  385. uni.setStorageSync("JTJInfo", this.JTJDetailInfo);
  386. },
  387. hideModal(e) {
  388. this.modalName = null;
  389. },
  390. searchEnterPrise() {
  391. this.pageNum = 1;
  392. this.pageTotal = 1;
  393. this.getEnterPriseList();
  394. },
  395. searchJTJ() {
  396. this.jpageNum = 1;
  397. this.jpageTotal = 1;
  398. this.getJTJTypeList();
  399. },
  400. getEnterPriseList() {
  401. const param = {
  402. pageNum: this.pageNum,
  403. pageSize: this.pageSize,
  404. towns: this.queryXzqdm
  405. };
  406. if (this.enterprisesName) {
  407. param.enterprisesName = this.enterprisesName;
  408. }
  409. _sampleDetail.getEnterPriseList(param, res => {
  410. const { data, message, code } = res;
  411. if (code === 200) {
  412. const { records, total } = data;
  413. this.pageTotal = Math.ceil(total / this.pageSize);
  414. if (this.pageNum === 1) {
  415. this.qyList = records;
  416. } else {
  417. this.qyList = this.qyList.concat(records);
  418. }
  419. this.pageNum++;
  420. } else {
  421. uni.showToast({
  422. icon: "none",
  423. title: message,
  424. duration: 1000
  425. });
  426. }
  427. });
  428. },
  429. getSampleList() {
  430. const param = {
  431. pageNum: this.spageNum,
  432. pageSize: this.spageSize,
  433. qydm: this.companyDetailInfo.qydm
  434. };
  435. _sampleDetail.getSampleByCompany(param, res => {
  436. const { data, message, code } = res;
  437. if (code === 200) {
  438. const { records, total } = data;
  439. console.log(records)
  440. this.spageTotal = Math.ceil(total / this.spageSize);
  441. if (this.spageNum === 1) {
  442. this.sampleList = records;
  443. console.log(this.sampleList)
  444. } else {
  445. this.sampleList = this.sampleList.concat(records);
  446. }
  447. this.spageNum++;
  448. } else {
  449. uni.showToast({
  450. icon: "none",
  451. title: message,
  452. duration: 1000
  453. });
  454. }
  455. });
  456. },
  457. getJTJTypeList() {
  458. const param = {
  459. pageNum: this.jpageNum,
  460. pageSize: this.jpageSize
  461. }
  462. _sampleDetail.getJTJTypeList(param, res => {
  463. const { data, message, code } = res;
  464. if (code === 200) {
  465. const { records, total } = data;
  466. this.jpageTotal = Math.ceil(total / this.jpageSize);
  467. if (this.jpageNum === 1) {
  468. this.JTJList = records;
  469. } else {
  470. this.JTJList = this.JTJList.concat(records);
  471. }
  472. this.jpageNum++;
  473. } else {
  474. uni.showToast({
  475. icon: "none",
  476. title: message,
  477. duration: 1000
  478. });
  479. }
  480. })
  481. }
  482. }
  483. }
  484. </script>
  485. <style>
  486. </style>