index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <view class="home padding-bottom">
  3. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  4. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png" :isBack="true">
  5. <block slot="content">企业抽检</block>
  6. </cu-custom>
  7. <view class="cu-form-group solid-bottom">
  8. <view class="title text-xl text-bold">
  9. <text class="cuIcon cuIcon-titles text-blue"></text>
  10. 抽样主体列表
  11. </view>
  12. <view>抽样批次数:
  13. <text class="text-bold text-lg">{{ batchNumber }}</text>
  14. </view>
  15. </view>
  16. <view class="padding-sm" style="margin-bottom: 130rpx">
  17. <view class="cu-list menu margin-top-sm taskDetail bg-white"
  18. v-for="(item, index) in sampleList" :key="index">
  19. <view class="cu-item">
  20. <view class="content text-black text-bold">
  21. <text class="cuIcon-titles text-green">{{ index + 1 }}.</text>
  22. {{ item.bySampleUnitName }}
  23. </view>
  24. <view class="action">
  25. </view>
  26. </view>
  27. <view class="content padding-sm detail solid-bottom">
  28. <view class="text-bold text-orange">当前状态:{{ setSampleStatus(item.sampleStatus) }}</view>
  29. <view>抽检样品:{{ item.mustProductName }}
  30. </view>
  31. <view>负责人:{{ item.bySampleContactName }}</view>
  32. <view>联系电话:{{ item.bySampleContactPhone }}</view>
  33. <view style="height: auto">企业地址:{{ item.bySampleAddress.replaceAll(",", "").replaceAll(" ", "")
  34. }}
  35. </view>
  36. </view>
  37. <view class="tools" style="justify-content: space-between">
  38. <view>
  39. </view>
  40. <!-- <view class="tool" v-if="item.ahTasks.status ==='TASK_RUNNING'"
  41. @tap="handleTaskDetail(item)">
  42. <view class="cu-tag bg-blue light text-df text-bold">去抽样 >></view>
  43. </view>-->
  44. <view class="tool" @tap="toFillSample(item)">
  45. <view class="text-blue text-df text-bold text">
  46. {{ getBtnName(item.sampleStatus) }}>>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="radius shadow-warp bg-white text-lg" v-if="sampleList.length === 0">
  52. <view class="cu-list menu-avatar">
  53. <view class="cu-item">
  54. <view class="content">
  55. <view class="text-sm text-center" style="justify-content: center;">
  56. <text class="text-cut text-lg">
  57. <text class="cuIcon-warn text-yellow margin-right-xs text-xl"></text>
  58. 未添加抽检主体数据
  59. </text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="padding flex flex-direction padding-bottom-xl fixedFootBtn bg-white padding-top">
  67. <button class="cu-btn bg-blue lg shadow-blur" type="" @tap="showFirstProductChoose"
  68. :disabled="sampleList.length >= batchNumber">抽取抽检主体
  69. </button>
  70. </view>
  71. <view class="cu-modal bottom-modal" :class="modalName==='productListModal'?'show':''">
  72. <view class="cu-dialog" @tap.stop.prevent>
  73. <view class="cu-bar bg-white">
  74. <view class="action text-blue" @tap="hideModal">取消</view>
  75. <view class="content text-bold">选择抽检样品</view>
  76. </view>
  77. <view class="bg-white">
  78. <view class="cu-bar search bg-white">
  79. <view class="search-form radius text-left">
  80. <text class="cuIcon-search"></text>
  81. <input type="text" placeholder="输入样品名称搜索" confirm-type="search"
  82. v-model="queryProName" />
  83. <text class="cuIcon cuIcon-close endClass text-xxl text-bold" @tap="resetQymcQuery"
  84. v-show="queryProName !== ''"></text>
  85. </view>
  86. <view class="action"><!-- 全部的按钮 -->
  87. <button class="cu-btn bg-green shadow-blur round" @tap="searchProduct">搜索</button>
  88. </view>
  89. </view>
  90. <scroll-view scroll-y class="productScroll padding" @scrolltolower="getProductList">
  91. <radio-group @change="productNameChange">
  92. <view class="flex flex-wrap">
  93. <view class="basis-df padding-xs text-left" v-for="(item,index) in productList"
  94. :key="index">
  95. <checkbox :value="item.productName" class="radio" :id="'productName'+index"
  96. :checked="sampleRandom.productName === item.productName"></checkbox>
  97. <label :for="'productName'+index">{{ item.productName }}</label>
  98. </view>
  99. </view>
  100. </radio-group>
  101. </scroll-view>
  102. </view>
  103. </view>
  104. </view>
  105. <view class="cu-modal" :class="modalName==='SureProductNameModal'?'show':''">
  106. <view class="cu-dialog">
  107. <view class="cu-bar bg-white justify-end">
  108. <view class="content">抽检企业</view>
  109. <view class="action" @tap="hideModal">
  110. <text class="cuIcon-close text-red"></text>
  111. </view>
  112. </view>
  113. <view class="padding-left padding-right padding-bottom-sm cu-list menu bg-white">
  114. <view class="cu-form-group">
  115. <view class="title">抽样样品名称</view>
  116. <picker :disabled="true" @tap="modalName = 'productListModal'">
  117. <view class="picker">
  118. {{ sampleRandom.productName }}
  119. </view>
  120. </picker>
  121. </view>
  122. <view class="cu-form-group" v-if="!isCounty">
  123. <view class="title">所属区域</view>
  124. <picker :range="regionArray" @change="RegionChange"
  125. :value="selectIndex">
  126. <view class="picker">
  127. {{ regionArray[selectIndex] || "请选择区域" }}
  128. </view>
  129. </picker>
  130. </view>
  131. <view class="cu-form-group solid-bottom">
  132. <view class="title">抽检主体数量</view>
  133. <input type="number" v-model.trim="sampleRandom.enterprisesNum"
  134. placeholder="请输入抽检主体数量">
  135. </view>
  136. <view class="text-right padding-right text-gray padding-top-sm"
  137. v-show="lastCmpNum !== null && lastCmpNum >= 0">
  138. <text>剩余可抽取主体:
  139. <text class="text-bold text-lg">{{ lastCmpNum }}</text>
  140. </text>
  141. </view>
  142. </view>
  143. <view class="padding flex flex-direction">
  144. <button class="cu-btn bg-green lg shadow-blur" type="" @tap="getEnterprisesList"
  145. :disabled="lastCmpNum == null || lastCmpNum === 0">抽取
  146. </button>
  147. </view>
  148. </view>
  149. </view>
  150. <view class="cu-modal" :class="modalName=='onSureSampleEnterpriseModel'?'show':''">
  151. <view class="cu-dialog">
  152. <view class="cu-bar bg-white justify-end">
  153. <view class="content">待确认抽检主体</view>
  154. <view class="action" @tap="hideModal">
  155. <text class="cuIcon-close text-red"></text>
  156. </view>
  157. </view>
  158. <view class="padding-left padding-right padding-bottom-sm cu-list menu bg-white">
  159. <scroll-view class="text-content" scroll-y>
  160. <view class="cu-item">
  161. <view class="title text-black text-bold text-lg text-left"
  162. v-for="(item,index) in onSureEnterpriseList"
  163. :key="index">
  164. <text class="cuIcon-title text-green margin-right-xs"></text>
  165. <text>{{ item.enterprisesName }}</text>
  166. </view>
  167. </view>
  168. </scroll-view>
  169. </view>
  170. <view class="cu-bar bg-green light" @tap="createSampleSheetList">
  171. <view class="action margin-0 flex-sub">确认</view>
  172. </view>
  173. </view>
  174. </view>
  175. </view>
  176. </template>
  177. <script>
  178. import {
  179. _sampleRandom
  180. } from "./sample-random-model";
  181. import { _taskList } from "../../task-list/task-list-model";
  182. export default {
  183. data() {
  184. return {
  185. taskId: null,
  186. sampleCheckId: null,
  187. batchNumber: 0,
  188. sampleRandom: {
  189. productName: "",
  190. enterprisesNum: ""
  191. },
  192. onSureEnterpriseList: [],
  193. productList: [],
  194. taskListData: [],
  195. taskTypeList: [],
  196. taskDetailList: [],
  197. taskStatus: [],
  198. modalName: null,
  199. xzqdm: null,
  200. pageTotal: 1,
  201. totalCount: 0,
  202. page: 1,
  203. size: 40,
  204. samplePage: 1,
  205. sampleSize: 10,
  206. samplePageTotal: 1,
  207. sampleTotalCount: 0,
  208. sampleList: [],
  209. zfrSelected: [],
  210. serviceZfrSelected: [],
  211. queryProName: "",
  212. subXzqList: [],
  213. selectIndex: null,
  214. lastCmpNum: null,
  215. sampleStatus: [],
  216. isCounty:false
  217. };
  218. },
  219. onLoad(param) {
  220. this.page = 1;
  221. this.pageTotal = 1;
  222. this.taskId = param.taskId;
  223. this.batchNumber = param.batchNumber;
  224. this.sampleCheckId = param.sampleCheckId;
  225. this.xzqdm = param.sampleId;
  226. if (this.xzqdm.endsWith("000") && !this.xzqdm.endsWith("00000")) {
  227. this.isCounty = true;
  228. }
  229. this.getProductList();
  230. this.getSampleCheckList();
  231. this.initXzqRange();
  232. this.getSampleStatus();
  233. },
  234. computed: {
  235. regionArray() {
  236. return this.subXzqList.map(v => v.xzqmc);
  237. },
  238. selectXzqCode() {
  239. if(this.isCounty){
  240. return this.xzqdm;
  241. } else {
  242. if (this.selectIndex !== null) {
  243. return this.subXzqList[this.selectIndex].xzqdm;
  244. }
  245. }
  246. }
  247. },
  248. methods: {
  249. showFirstProductChoose() {
  250. this.sampleRandom.enterprisesNum = null;
  251. this.sampleRandom.productName = null;
  252. this.modalName = "productListModal";
  253. },
  254. getSampleCheckList() {
  255. if (this.samplePage === 1 || (this.samplePage <= this.samplePageTotal)) {
  256. _sampleRandom.getSampleCheckList({
  257. pageNum: this.samplePage,
  258. pageSize: this.sampleSize,
  259. sampleCheckId: this.sampleCheckId
  260. }, res => {
  261. const { data, message, code } = res;
  262. if (code === 200) {
  263. const { records, total } = data;
  264. this.sampleTotalCount = total;
  265. this.samplePageTotal = Math.ceil(total / this.sampleSize);
  266. if (this.samplePage === 1) {
  267. this.sampleList = records;
  268. } else {
  269. this.sampleList = this.sampleList.concat(records);
  270. }
  271. this.samplePage++;
  272. } else {
  273. uni.showToast({
  274. icon: "none",
  275. title: message,
  276. duration: 1000
  277. });
  278. }
  279. });
  280. }
  281. },
  282. searchProduct() {
  283. this.page = 1;
  284. this.pageTotal = 1;
  285. this.getProductList();
  286. },
  287. resetQymcQuery() {
  288. this.queryProName = "";
  289. this.searchProduct();
  290. },
  291. getProductList() {
  292. if (this.page === 1 || (this.page <= this.pageTotal)) {
  293. _sampleRandom.getProductList({
  294. pageNum: this.page,
  295. pageSize: this.size,
  296. xzqCode: this.xzqdm,
  297. productName: this.queryProName
  298. }, res => {
  299. const { data, message, code } = res;
  300. if (code === 200) {
  301. const { list, total } = data;
  302. this.totalCount = total;
  303. this.pageTotal = Math.ceil(total / this.size);
  304. if (this.page === 1) {
  305. this.productList = list;
  306. } else {
  307. this.productList = this.productList.concat(list);
  308. }
  309. this.page++;
  310. } else {
  311. uni.showToast({
  312. icon: "none",
  313. title: message,
  314. duration: 1000
  315. });
  316. }
  317. });
  318. }
  319. },
  320. getEnterPrisesNum() {
  321. if (this.selectXzqCode !== "" && this.selectXzqCode !== null && this.sampleRandom.productName) {
  322. _sampleRandom.getEnterPrisesNum({
  323. xzqCode: this.selectXzqCode,
  324. productName: this.sampleRandom.productName
  325. }, res => {
  326. this.lastCmpNum = res.data;
  327. });
  328. } else {
  329. this.lastCmpNum = null;
  330. }
  331. },
  332. showModal(e) {
  333. this.modalName = e.currentTarget.dataset.target;
  334. _sampleRandom.getTaskSampleDetail(e.currentTarget.dataset.taskid, res => {
  335. this.taskDetailList = res.data.records;
  336. });
  337. },
  338. hideModal(e) {
  339. this.curTask = null;
  340. this.modalName = null;
  341. },
  342. createSampleSheetList() {
  343. if (this.onSureEnterpriseList.length <= 0) {
  344. this.$msg("抽检企业为空");
  345. return;
  346. }
  347. const postData = this.onSureEnterpriseList.map(v => {
  348. return {
  349. bySampleAddress: v.enterprisesAddress,
  350. bySampleContactName: v.fzrName,
  351. bySampleContactPhone: v.fzrPhone,
  352. bySampleUnitName: v.enterprisesName,
  353. mustProductName: this.sampleRandom.productName,
  354. qydm: v.qydm,
  355. taskId: this.taskId,
  356. sampleCheckId: this.sampleCheckId
  357. };
  358. });
  359. _sampleRandom.createSampleSheetList(postData, res => {
  360. const { code, message } = res;
  361. if (code === 200) {
  362. this.$msg("添加成功");
  363. this.modalName = null;
  364. this.samplePage = 1;
  365. this.samplePageTotal = 1;
  366. this.getSampleCheckList();
  367. } else {
  368. this.$msg(message);
  369. }
  370. });
  371. },
  372. getEnterprisesList() {
  373. // this.onSureEnterpriseList = true;
  374. if (!this.isCounty && this.selectIndex === null) {
  375. this.$msg("请选择抽样区域");
  376. return;
  377. }
  378. const postData = Object.assign({}, this.sampleRandom);
  379. if (!postData.productName) {
  380. this.$msg("请选择抽样样品名称");
  381. return;
  382. }
  383. if (parseInt(postData.enterprisesNum) <= 0 || "" + parseInt(postData.enterprisesNum) === "NaN") {
  384. this.$msg("请输入抽检主体数量");
  385. return;
  386. }
  387. if (parseInt(postData.enterprisesNum) + this.sampleList.length > this.batchNumber) {
  388. this.$msg("抽取企业总数不可超过抽样批次数");
  389. return;
  390. }
  391. if (parseInt(postData.enterprisesNum) > parseInt(this.lastCmpNum)) {
  392. this.$msg("抽检主体数量应小于等于剩余主体数量");
  393. return;
  394. }
  395. postData.xzqCode = this.selectXzqCode;
  396. postData.taskId = this.taskId;
  397. _sampleRandom.getEnterprisesList(postData, res => {
  398. if (!res.data || res.data.length === 0) {
  399. this.$msg("当前地区无可抽取企业");
  400. } else {
  401. this.onSureEnterpriseList = res.data;
  402. this.modalName = "onSureSampleEnterpriseModel";
  403. }
  404. });
  405. },
  406. setTaskType(taskType) {
  407. const taskTypeList = this.taskTypeList;
  408. for (let i = 0; i < taskTypeList.length; i++) {
  409. if (taskTypeList[i].itemValue === taskType) {
  410. return taskTypeList[i].itemKey;
  411. }
  412. }
  413. },
  414. setTaskStatus(value) {
  415. let taskStatus = this.taskStatus;
  416. for (let i = 0; i < taskStatus.length; i++) {
  417. if (taskStatus[i].itemValue === value) {
  418. return taskStatus[i].itemKey;
  419. }
  420. }
  421. },
  422. formatDate(dateTime) {
  423. return dateTime.substring(0, 10);
  424. },
  425. productNameChange(e) {
  426. const productName = e.detail.value;
  427. if (productName) {
  428. this.sampleRandom.productName = productName;
  429. this.getEnterPrisesNum();
  430. this.modalName = "SureProductNameModal";
  431. }
  432. },
  433. initXzqRange() {
  434. _sampleRandom.getXzqdmSubLists(this.xzqdm, city_res => {
  435. const { code, data } = city_res;
  436. if (code === 200) {
  437. this.subXzqList = data;
  438. }
  439. });
  440. },
  441. RegionChange(e) {
  442. this.selectIndex = e.detail.value;
  443. this.getEnterPrisesNum();
  444. },
  445. getSampleStatus() {
  446. _taskList.getDictionary("SAMPLE_SHEET_STATUS", res => {
  447. this.sampleStatus = res.data;
  448. });
  449. },
  450. setSampleStatus(value) {
  451. console.log("setSampleStatus",value);
  452. let sampleStatus = this.sampleStatus;
  453. for (let i = 0; i < sampleStatus.length; i++) {
  454. if (sampleStatus[i].itemValue === value) {
  455. return sampleStatus[i].itemKey;
  456. }
  457. }
  458. },
  459. toFillSample(item) {
  460. uni.navigateTo({
  461. url: "/pages/sample-detail/index?id=" + item.id
  462. });
  463. },
  464. getBtnName(status) {
  465. let name = "查看";
  466. if (status === "WAIT_SAMPLE") {
  467. name = "填报抽样单";
  468. }
  469. return name;
  470. }
  471. }
  472. };
  473. </script>
  474. <style scoped>
  475. .detail view {
  476. font-size: 31rpx;
  477. height: 1.8em;
  478. line-height: 1.8em !important;
  479. border: none;
  480. }
  481. .taskDetail {
  482. /*border: 1rpx solid #8799a3;*/
  483. box-shadow: 0 0 25upx #aaa;
  484. border-radius: 10rpx;
  485. overflow: hidden;
  486. }
  487. label {
  488. padding-left: .5em;
  489. }
  490. .productScroll {
  491. height: 30em;
  492. max-height: 60vh;
  493. }
  494. .fixedFootBtn {
  495. border-top: 1px solid #ddd;
  496. position: fixed;
  497. width: 100vw;
  498. bottom: 0;
  499. z-index: 1000;
  500. }
  501. .tools {
  502. display: flex;
  503. align-items: center;
  504. justify-content: space-between;
  505. padding: 30upx;
  506. }
  507. .tool .text {
  508. font-size: 1.1em !important;
  509. }
  510. </style>