index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <div class="tenant">
  3. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading"
  4. :selectConfig="selectConfig" :action-list="actionList" @get-list="getList"
  5. @moreSearch="() => queryDialogVisible = true" :table-events="tableEvents">
  6. </byTable>
  7. <!--高级搜索-->
  8. <el-dialog :title="'高级检索'" v-model="queryDialogVisible" width="500px" destroy-on-close>
  9. <el-form label-width="auth">
  10. <!-- <el-form-item label="申请日期">-->
  11. <!-- <el-date-picker v-model="sourceList.pagination.applyDate" value-format="YYYY-MM-DD" type="daterange"/>-->
  12. <!-- </el-form-item>-->
  13. </el-form>
  14. <template #footer>
  15. <el-button @click="handleReset" size="large">重置</el-button>
  16. <el-button @click="handleQuery" type="primary" size="large">搜索</el-button>
  17. </template>
  18. </el-dialog>
  19. <el-dialog title="处理" v-model="visible" width="500px" destroy-on-close>
  20. <el-form label-position="right" label-width="auto">
  21. <el-form-item label="报废数量">
  22. <el-input-number v-model="formData.scrappedCount" style="width: 100%" :controls="false"
  23. disabled></el-input-number>
  24. </el-form-item>
  25. <el-form-item label="转良品数量">
  26. <el-input-number v-model="formData.scrappedToQualifiedCount" style="width: 100%" :controls="false" :min="0"
  27. :max="formData.scrappedCount" :precision="0"/>
  28. </el-form-item>
  29. <el-form-item label="转次品数量">
  30. <el-input-number v-model="formData.scrappedToDefectiveCount" style="width: 100%" :controls="false" :min="0"
  31. :max="formData.scrappedCount" :precision="0"/>
  32. </el-form-item>
  33. <el-form-item label="最终报废数量">
  34. <el-input-number v-model="formData.resultScrappedCount" style="width: 100%" :controls="false" :min="0"
  35. :max="formData.scrappedCount" :precision="0"/>
  36. </el-form-item>
  37. </el-form>
  38. <template #footer>
  39. <el-button @click="visible = false" size="large">取消</el-button>
  40. <el-button @click="submit" type="primary" size="large">确定</el-button>
  41. </template>
  42. </el-dialog>
  43. <el-dialog title="批量处理" v-model="batchVisible" width="1200px" destroy-on-close>
  44. <el-table :data="handleSelectData">
  45. <el-table-column prop="code" label="质检单号"/>
  46. <el-table-column prop="productCustomCode" label="物品编码"/>
  47. <el-table-column prop="productName" label="物品名称"/>
  48. <el-table-column prop="scrappedCount" label="报废数量"/>
  49. <el-table-column prop="scrappedToQualifiedCount" label="报废转良品数量">
  50. <template #default="scope">
  51. <el-input-number v-model="scope.row.scrappedToQualifiedCount" style="width: 100%" :controls="false" :min="0"
  52. :max="scope.row.scrappedCount" :precision="0"/>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="scrappedToDefectiveCount" label="报废转次品数量">
  56. <template #default="scope">
  57. <el-input-number v-model="scope.row.scrappedToDefectiveCount" style="width: 100%" :controls="false" :min="0"
  58. :max="scope.row.scrappedCount" :precision="0"/>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="resultScrappedCount" label="最终报废数量">
  62. <template #default="scope">
  63. <el-input-number v-model="scope.row.resultScrappedCount" style="width: 100%" :controls="false" :min="0"
  64. :max="scope.row.scrappedCount" :precision="0"/>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <template #footer>
  69. <el-button @click="batchVisible = false" size="large">取消</el-button>
  70. <el-button @click="batchSubmit" type="primary" size="large">确定</el-button>
  71. </template>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script setup>
  76. import byTable from "@/components/byTable/index";
  77. import {computed, getCurrentInstance, ref} from "vue";
  78. import {ElMessage} from "element-plus";
  79. const {proxy} = getCurrentInstance();
  80. const loading = ref(false);
  81. const visible = ref(false);
  82. const batchVisible = ref(false);
  83. const queryDialogVisible = ref(false);
  84. const formData = ref({})
  85. const selectData = ref([]);
  86. const handleSelectData = ref([]);
  87. const sourceList = ref({
  88. data: [],
  89. pagination: {
  90. total: 0,
  91. pageNum: 1,
  92. pageSize: 10,
  93. scrappedHandleStatus: undefined
  94. },
  95. });
  96. const tableEvents = computed(() => {
  97. return {
  98. 'selection-change': (val) => {
  99. selectData.value = val;
  100. handleSelectData.value = []
  101. selectData.value.forEach(item => {
  102. handleSelectData.value.push({...item, resultScrappedCount: item.scrappedCount})
  103. });
  104. },
  105. }
  106. })
  107. const selectConfig = ref([
  108. {
  109. label: "状态",
  110. prop: "scrappedHandleStatus",
  111. data: [
  112. {
  113. label: "待处理",
  114. value: "1",
  115. },
  116. {
  117. label: "待验证",
  118. value: "2",
  119. },
  120. {
  121. label: "已验证",
  122. value: "3",
  123. },
  124. ],
  125. },
  126. {
  127. label: "项目组",
  128. prop: "deptId",
  129. },
  130. ]);
  131. const actionList = computed(() => {
  132. return [
  133. {
  134. text: '批量处理',
  135. disabled: selectData.value.length === 0,
  136. action: () => {
  137. batchVisible.value = true;
  138. }
  139. }
  140. ]
  141. });
  142. const config = computed(() => {
  143. return [
  144. {
  145. type: "selection",
  146. attrs: {
  147. checkAtt: "isCheck",
  148. },
  149. },
  150. {
  151. attrs: {
  152. label: "质检单号",
  153. prop: "code",
  154. align: "left",
  155. },
  156. },
  157. {
  158. attrs: {
  159. label: "物品编码",
  160. prop: "productCustomCode",
  161. align: "left",
  162. },
  163. },
  164. {
  165. attrs: {
  166. label: "物品名称",
  167. prop: "productName",
  168. align: "left",
  169. },
  170. },
  171. {
  172. attrs: {
  173. label: "规格",
  174. prop: "productSpec",
  175. align: "left",
  176. },
  177. },
  178. {
  179. attrs: {
  180. label: "单位",
  181. prop: "productUnit",
  182. align: "left",
  183. },
  184. },
  185. {
  186. attrs: {
  187. label: "报废数量",
  188. prop: "scrappedCount",
  189. align: "left",
  190. },
  191. },
  192. {
  193. attrs: {
  194. label: "报废转良品数量",
  195. prop: "scrappedToQualifiedCount",
  196. align: "left",
  197. },
  198. },
  199. {
  200. attrs: {
  201. label: "报废转次品数量",
  202. prop: "scrappedToDefectiveCount",
  203. align: "left",
  204. },
  205. },
  206. {
  207. attrs: {
  208. label: "最终报废数量",
  209. prop: "resultScrappedCount",
  210. align: "left",
  211. },
  212. },
  213. {
  214. attrs: {
  215. label: "状态",
  216. prop: "scrappedHandleStatus",
  217. align: "left",
  218. },
  219. render(scrappedHandleStatus) {
  220. switch (scrappedHandleStatus) {
  221. case 1:
  222. return '待处理'
  223. case 2:
  224. return '待验证'
  225. case 3:
  226. return '已验证'
  227. }
  228. return '未知状态';
  229. },
  230. },
  231. {
  232. attrs: {
  233. label: "生成时间",
  234. prop: "createTime",
  235. align: "left",
  236. width: 160
  237. },
  238. },
  239. {
  240. attrs: {
  241. label: "处理时间",
  242. prop: "scrappedHandleTime",
  243. align: "left",
  244. width: 160
  245. },
  246. },
  247. {
  248. attrs: {
  249. label: "操作",
  250. align: "center",
  251. fixed: "right",
  252. width: 120
  253. },
  254. renderHTML(row) {
  255. if (row.scrappedHandleStatus === 1) {
  256. return [{
  257. attrs: {
  258. label: "处理",
  259. type: "primary",
  260. text: true,
  261. },
  262. el: "button",
  263. click() {
  264. visible.value = true
  265. formData.value = {...row, resultScrappedCount: row.scrappedCount}
  266. },
  267. }]
  268. }
  269. }
  270. }
  271. ];
  272. });
  273. const getDeptList = () => {
  274. proxy.get("/jdRefundQualityCheck/deptList", {})
  275. .then(({data}) => {
  276. console.log(data)
  277. selectConfig.value[1].data = data.map((item) => {
  278. return {
  279. label: item.deptName,
  280. value: item.deptId,
  281. };
  282. });
  283. })
  284. selectConfig.value = JSON.parse(JSON.stringify(selectConfig.value));
  285. }
  286. getDeptList();
  287. const getList = async (req) => {
  288. loading.value = true;
  289. sourceList.value.pagination = {...sourceList.value.pagination, ...req}
  290. const queryData = {...sourceList.value.pagination, ...req, status: [1, 2, 3]};
  291. const applyDate = queryData.applyDate;
  292. if (applyDate?.length === 2) {
  293. delete queryData.applyDate
  294. queryData.beginTime = applyDate[0]
  295. queryData.endTime = applyDate[1]
  296. }
  297. proxy.get("/jdRefundQualityCheck/getPage", queryData)
  298. .then(({data}) => {
  299. sourceList.value.data = data.rows;
  300. sourceList.value.pagination.total = data.total;
  301. for (let item of sourceList.value.data) {
  302. if (item.scrappedHandleStatus === 1) {
  303. item.isCheck = true
  304. }
  305. }
  306. })
  307. .finally(_ => {
  308. loading.value = false;
  309. })
  310. };
  311. const handleReset = () => {
  312. sourceList.value.pagination = {
  313. pageNum: sourceList.value.pagination.pageNum,
  314. pageSize: sourceList.value.pagination.pageSize,
  315. };
  316. handleQuery();
  317. };
  318. const handleQuery = () => {
  319. queryDialogVisible.value = false;
  320. getList();
  321. };
  322. const submit = () => {
  323. const {scrappedCount, scrappedToQualifiedCount, scrappedToDefectiveCount, resultScrappedCount} = formData.value
  324. if (scrappedCount !== scrappedToQualifiedCount + scrappedToDefectiveCount + resultScrappedCount) {
  325. ElMessage.error("转良品数量+转次品数量+最终报废数量 必须等于 报废数量")
  326. return
  327. }
  328. proxy.post("/jdRefundQualityCheck/handle", formData.value)
  329. .then(() => {
  330. ElMessage.success("处理成功")
  331. visible.value = false;
  332. getList()
  333. })
  334. }
  335. const batchSubmit = () => {
  336. for (let item of handleSelectData.value) {
  337. const {scrappedCount, scrappedToQualifiedCount, scrappedToDefectiveCount, resultScrappedCount} = item
  338. if (scrappedCount !== scrappedToQualifiedCount + scrappedToDefectiveCount + resultScrappedCount) {
  339. ElMessage.error(`产品【${item.productCustomCode}】转良品数量+转次品数量+最终报废数量 必须等于 报废数量`)
  340. return
  341. }
  342. }
  343. proxy.post("/jdRefundQualityCheck/batchHandle", handleSelectData.value)
  344. .then(() => {
  345. ElMessage.success("批量处理成功")
  346. batchVisible.value = false;
  347. getList()
  348. })
  349. }
  350. getList();
  351. </script>
  352. <style lang='scss' scoped>
  353. .tenant {
  354. padding: 20px;
  355. }
  356. .el-table .error-row {
  357. background: rgba(245, 108, 108, 0.68);
  358. }
  359. </style>