index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: selectRow,
  15. }"
  16. :action-list="[
  17. {
  18. text: '质检',
  19. disabled: selectData.length === 0,
  20. action: () => start(20),
  21. },
  22. ]"
  23. @get-list="getList"
  24. >
  25. <template #fileSlot="{ item }">
  26. <div
  27. style="cursor: pointer; color: #409eff"
  28. @click="handleClickFile(item)"
  29. >
  30. {{ item.fileName }}
  31. </div>
  32. </template>
  33. </byTable>
  34. </div>
  35. <el-dialog
  36. title="到货质检"
  37. v-model="dialogVisible"
  38. width="800"
  39. v-loading="loading"
  40. >
  41. <byForm
  42. :formConfig="formConfig"
  43. :formOption="formOption"
  44. v-model="formData.data"
  45. :rules="rules"
  46. ref="byform"
  47. >
  48. <template #products>
  49. <div style="width: 100%">
  50. <el-table :data="formData.data.stockTransferDetailsList">
  51. <el-table-column prop="productCode" label="物品类型" />
  52. <el-table-column prop="productCode" label="物品编码" />
  53. <el-table-column prop="productName" label="物品名称" />
  54. <el-table-column prop="productSpec" label="规格型号" />
  55. <el-table-column prop="productSpec" label="单位" />
  56. <el-table-column prop="inQuantity" label="到货数量" />
  57. <el-table-column prop="outQuantity" label="已质检" />
  58. <el-table-column
  59. prop="outQuantity"
  60. label="质检合格"
  61. min-width="150"
  62. >
  63. <template #default="{ row, $index }">
  64. <el-form-item
  65. :prop="
  66. 'stockTransferDetailsList.' + $index + '.outQuantity'
  67. "
  68. :rules="rules.outQuantity"
  69. :inline-message="true"
  70. >
  71. <el-input-number
  72. v-model="row.outQuantity"
  73. :precision="2"
  74. :controls="false"
  75. :min="0"
  76. />
  77. </el-form-item>
  78. </template>
  79. </el-table-column>
  80. <el-table-column
  81. prop="inQuantity"
  82. label="质检不合格"
  83. min-width="150"
  84. >
  85. <template #default="{ row, $index }">
  86. <el-form-item
  87. :prop="'stockTransferDetailsList.' + $index + '.inQuantity'"
  88. :rules="rules.inQuantity"
  89. :inline-message="true"
  90. >
  91. <el-input-number
  92. v-model="row.inQuantity"
  93. :precision="2"
  94. :controls="false"
  95. :min="0"
  96. />
  97. </el-form-item>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. </div>
  102. </template>
  103. </byForm>
  104. <template #footer>
  105. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  106. <el-button
  107. type="primary"
  108. @click="submitForm()"
  109. size="large"
  110. :loading="submitLoading"
  111. >
  112. 确 定
  113. </el-button>
  114. </template>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script setup>
  119. import { ElMessage, ElMessageBox } from "element-plus";
  120. import byTable from "@/components/byTable/index";
  121. import byForm from "@/components/byForm/index";
  122. const loading = ref(false);
  123. const submitLoading = ref(false);
  124. const sourceList = ref({
  125. data: [],
  126. pagination: {
  127. total: 3,
  128. pageNum: 1,
  129. pageSize: 10,
  130. },
  131. });
  132. let dialogVisible = ref(false);
  133. let modalType = ref("add");
  134. let rules = ref({
  135. name: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
  136. qualifiedCount: [
  137. { required: true, message: "请输入质检合格数量", trigger: "blur" },
  138. ],
  139. noQualifiedCount: [
  140. { required: true, message: "请输入质检不合格数量", trigger: "blur" },
  141. ],
  142. });
  143. const { proxy } = getCurrentInstance();
  144. const selectConfig = reactive([
  145. {
  146. label: "质检状态",
  147. prop: "status",
  148. data: [
  149. {
  150. label: "未质检",
  151. value: "0",
  152. },
  153. {
  154. label: "部分质检",
  155. value: "10",
  156. },
  157. {
  158. label: "已质检",
  159. value: "20",
  160. },
  161. ],
  162. },
  163. ]);
  164. const config = computed(() => {
  165. return [
  166. {
  167. type: "selection",
  168. attrs: {
  169. checkAtt: "isCheck",
  170. },
  171. },
  172. {
  173. attrs: {
  174. label: "采购单号",
  175. prop: "code",
  176. },
  177. },
  178. {
  179. attrs: {
  180. label: "供应商",
  181. prop: "supplyName",
  182. },
  183. },
  184. {
  185. attrs: {
  186. label: "物流/快递公司",
  187. prop: "productType",
  188. },
  189. },
  190. {
  191. attrs: {
  192. label: "物流/快递单号",
  193. prop: "productCode",
  194. },
  195. },
  196. {
  197. attrs: {
  198. label: "采购员",
  199. prop: "productName",
  200. },
  201. },
  202. {
  203. attrs: {
  204. label: "采购时间",
  205. prop: "productSpec",
  206. },
  207. },
  208. {
  209. attrs: {
  210. label: "质检状态",
  211. prop: "productUnit",
  212. },
  213. },
  214. {
  215. attrs: {
  216. label: "操作",
  217. width: "100",
  218. align: "right",
  219. },
  220. // 渲染 el-button,一般用在最后一列。
  221. renderHTML(row) {
  222. return [
  223. row.status == 20
  224. ? {
  225. attrs: {
  226. label: "质检",
  227. type: "primary",
  228. text: true,
  229. },
  230. el: "button",
  231. click() {
  232. selectDataOne.value = [row];
  233. start(10);
  234. },
  235. }
  236. : {},
  237. ];
  238. },
  239. },
  240. ];
  241. });
  242. let formData = reactive({
  243. data: {},
  244. });
  245. const formOption = reactive({
  246. inline: true,
  247. labelWidth: 100,
  248. itemWidth: 100,
  249. rules: [],
  250. });
  251. const formConfig = reactive([
  252. {
  253. type: "title",
  254. title: "到货信息",
  255. },
  256. {
  257. type: "select",
  258. prop: "outWarehouseId",
  259. label: "供应商",
  260. disabled: true,
  261. },
  262. {
  263. type: "select",
  264. prop: "inWarehouseId",
  265. label: "物流快递信息",
  266. placeholder: "物流/快递公司",
  267. itemWidth: 20,
  268. disabled: true,
  269. },
  270. {
  271. type: "input",
  272. prop: "remark",
  273. label: " ",
  274. itemWidth: 30,
  275. placeholder: "物流/快递单号",
  276. disabled: true,
  277. },
  278. {
  279. type: "title",
  280. title: "质检明细",
  281. },
  282. {
  283. type: "slot",
  284. slotName: "products",
  285. },
  286. ]);
  287. const byform = ref(null);
  288. const getList = async (req) => {
  289. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  290. loading.value = true;
  291. proxy
  292. .post("/arrivalDetail/page", sourceList.value.pagination)
  293. .then((message) => {
  294. message.rows.forEach((x) => {
  295. if (x.status < 20) {
  296. x.isCheck = true;
  297. } else {
  298. x.isCheck = false;
  299. }
  300. });
  301. sourceList.value.data = message.rows;
  302. sourceList.value.pagination.total = message.total;
  303. setTimeout(() => {
  304. loading.value = false;
  305. }, 200);
  306. });
  307. };
  308. const submitForm = () => {
  309. byform.value.handleSubmit((valid) => {
  310. const list = formData.data.qualityDetailList;
  311. for (let i = 0; i < list.length; i++) {
  312. const e = list[i];
  313. if (!(e.qualifiedCount + e.noQualifiedCount > 0)) {
  314. return ElMessage({
  315. message: "质检数量不能为0!",
  316. type: "info",
  317. });
  318. }
  319. if (
  320. e.qualifiedCount + e.noQualifiedCount + Number(e.sumQualityCount) >
  321. Number(e.count)
  322. ) {
  323. return ElMessage({
  324. message: "质检数量不能大于到货数量!",
  325. type: "info",
  326. });
  327. }
  328. }
  329. submitLoading.value = true;
  330. proxy.post("/quality/" + modalType.value, formData.data).then(
  331. (res) => {
  332. ElMessage({
  333. message: "质检成功",
  334. type: "success",
  335. });
  336. dialogVisible.value = false;
  337. submitLoading.value = false;
  338. getList();
  339. },
  340. (err) => {
  341. submitLoading.value = false;
  342. }
  343. );
  344. });
  345. };
  346. const getDtl = (row) => {
  347. modalType.value = "edit";
  348. dialogVisible.value = true;
  349. // proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
  350. // formData.data = res;
  351. // dialogVisible.value = true;
  352. // });
  353. };
  354. getList();
  355. const selectData = ref([]);
  356. const selectDataOne = ref([]);
  357. const selectRow = (data) => {
  358. selectData.value = data;
  359. };
  360. const start = (type) => {
  361. modalType.value = "add";
  362. let ids = [];
  363. let row = {};
  364. if (type === 10) {
  365. row = selectDataOne.value[0];
  366. ids = selectDataOne.value.map((x) => x.id);
  367. } else if (type === 20) {
  368. ids = selectData.value.map((x) => x.id);
  369. row = selectData.value[0];
  370. }
  371. proxy.post("/arrivalDetail/detail", { ids }).then((res) => {
  372. formData.data = {
  373. arrivalId: row.arrivalId,
  374. supplyId: row.supplyId,
  375. supplyName: row.supplyName,
  376. code: row.code,
  377. qualityDetailList: res.map((x) => ({
  378. ...x,
  379. arrivalDetailId: x.id,
  380. qualifiedCount: 0,
  381. noQualifiedCount: 0,
  382. })),
  383. };
  384. dialogVisible.value = true;
  385. });
  386. };
  387. // watch(selectData, (newVal, oldVal) => {
  388. // if (newVal.length == 0) {
  389. // sourceList.value.data.forEach((x) => {
  390. // if (x.status < 20) {
  391. // x.isCheck = true;
  392. // } else {
  393. // x.isCheck = false;
  394. // }
  395. // });
  396. // } else if (newVal.length == 1) {
  397. // const current = newVal[0];
  398. // sourceList.value.data.forEach((x) => {
  399. // if (x.arrivalId !== current.arrivalId || x.status == 20) {
  400. // x.isCheck = false;
  401. // }
  402. // });
  403. // }
  404. // });
  405. onMounted(() => {});
  406. </script>
  407. <style lang="scss" scoped>
  408. .tenant {
  409. padding: 20px;
  410. }
  411. .el-checkbox {
  412. display: none;
  413. }
  414. </style>