index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud
  4. ref="crudRef"
  5. v-model:search="search"
  6. v-model="form"
  7. :data="data"
  8. :option="option"
  9. v-model:page="page"
  10. @row-save="createRow"
  11. @row-update="updateRow"
  12. @row-del="deleteRow"
  13. @search-change="searchChange"
  14. @search-reset="resetChange"
  15. @size-change="dataList"
  16. @current-change="dataList"
  17. :row-style="rowStyle"
  18. :cell-style="cellStyle"
  19. @selection-change="selectionChange"
  20. >
  21. <template #menu="{ size, row, index }">
  22. <el-button
  23. icon="el-icon-info"
  24. text
  25. @click="openDialog(row.id)"
  26. type="primary"
  27. :size="size"
  28. >
  29. 详情</el-button
  30. >
  31. </template>
  32. </avue-crud>
  33. <el-dialog
  34. v-model="dialog1.visible"
  35. :title="dialog1.title"
  36. width="950px"
  37. @close="dialog1.visible = false"
  38. >
  39. <work-order-page
  40. :queryType="2"
  41. :workOrderState="6"
  42. @order-info="materialInfo1"
  43. />
  44. </el-dialog>
  45. <el-dialog
  46. v-model="dialog2.visible"
  47. :title="dialog2.title"
  48. width="950px"
  49. @close="dialog2.visible = false"
  50. >
  51. <work-order-seqNos-page
  52. :workOrderCode="form.workOrderCode"
  53. @order-info="materialInfo2"
  54. />
  55. </el-dialog>
  56. <el-dialog
  57. v-model="dialog3.visible"
  58. :title="dialog3.title"
  59. width="950px"
  60. @close="dialog3.visible = false"
  61. >
  62. <Details
  63. :id="selectId"
  64. @close="
  65. dialog3.visible = false;
  66. dataList();
  67. "
  68. />
  69. </el-dialog>
  70. </div>
  71. </template>
  72. <script setup>
  73. import { ref, getCurrentInstance } from "vue";
  74. import { useCrud } from "@/hooks/userCrud";
  75. import ButtonPermKeys from "@/common/configs/buttonPermission";
  76. import { useCommonStoreHook } from "@/store";
  77. import dictDataUtil from "@/common/configs/dictDataUtil";
  78. import { useDictionaryStore } from "@/store";
  79. import Details from "./components/details.vue";
  80. const { dicts } = useDictionaryStore();
  81. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  82. // 传入一个url,后面不带/
  83. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  84. useCrud({
  85. src: "/api/v1/semiFinishedStock",
  86. });
  87. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  88. Methords; //增删改查
  89. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  90. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  91. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  92. const openDialog = (id) => {
  93. selectId.value = id;
  94. dialog3.visible = true;
  95. };
  96. const dialog1 = reactive({
  97. title: "工单号选择",
  98. visible: false,
  99. });
  100. const dialog2 = reactive({
  101. title: "流转卡号选择",
  102. visible: false,
  103. });
  104. const dialog3 = reactive({
  105. title: "详情",
  106. visible: false,
  107. });
  108. const selectId = ref(null);
  109. const materialInfo1 = (value) => {
  110. if (form.value.stockType == "1") {
  111. form.value.inWorkOrderId = value.workOrderCode;
  112. } else if (form.value.stockType == "2") {
  113. form.value.outWorkOrderId = value.workOrderCode;
  114. }
  115. form.value.workOrderId = value.id;
  116. form.value.workOrderSeqNos = [];
  117. dialog1.visible = false;
  118. };
  119. const materialInfo2 = (value) => {
  120. form.value.workOrderSeqNos = value;
  121. dialog2.visible = false;
  122. };
  123. const seqDisabled = computed(() => {
  124. return !form.value.workOrderId;
  125. });
  126. // 设置表格列或者其他自定义的option
  127. option.value = Object.assign(option.value, {
  128. delBtn: false,
  129. selection: true,
  130. labelWidth: 100,
  131. editBtn: false,
  132. viewBtn: false,
  133. column: [
  134. {
  135. label: "产品编码",
  136. prop: "materialCode",
  137. editDisabled: true,
  138. addDisplay: false,
  139. rules: [
  140. {
  141. required: true,
  142. trigger: "trigger",
  143. },
  144. ],
  145. },
  146. {
  147. label: "工艺路线名称",
  148. prop: "processRouteName",
  149. editDisabled: true,
  150. addDisplay: false,
  151. rules: [
  152. {
  153. required: true,
  154. trigger: "trigger",
  155. },
  156. ],
  157. },
  158. {
  159. label: "库存数量",
  160. prop: "stockNum",
  161. editDisabled: true,
  162. addDisplay: false,
  163. rules: [
  164. {
  165. required: true,
  166. trigger: "trigger",
  167. },
  168. ],
  169. },
  170. {
  171. label: "出库/入库数量",
  172. prop: "operateNum",
  173. addDisplay: false,
  174. editDisabled: true,
  175. rules: [
  176. {
  177. required: true,
  178. trigger: "trigger",
  179. },
  180. ],
  181. },
  182. {
  183. label: "出入库类型",
  184. prop: "stockType",
  185. editDisabled: true,
  186. addDisplay: true,
  187. rules: [
  188. {
  189. required: true,
  190. trigger: "trigger",
  191. },
  192. ],
  193. type: "select",
  194. dicData: [
  195. {
  196. label: "入库",
  197. value: "1",
  198. },
  199. {
  200. label: "出库",
  201. value: "2",
  202. },
  203. ],
  204. control: (val, form) => {
  205. return {
  206. inWorkOrderId: {
  207. display: val == "1",
  208. },
  209. outWorkOrderId: {
  210. display: val == "2",
  211. },
  212. };
  213. },
  214. },
  215. {
  216. label: "入库工单",
  217. prop: "inWorkOrderId",
  218. editDisabled: true,
  219. display: true,
  220. addDisplay: false,
  221. rules: [
  222. {
  223. required: true,
  224. trigger: "trigger",
  225. },
  226. ],
  227. type: "select",
  228. click: ({ value, column }) => {
  229. if (column.boxType) {
  230. dialog1.visible = true;
  231. }
  232. },
  233. change: ({ value, column }) => {
  234. if (value != form.value.materialCode) {
  235. dialog1.visible = true;
  236. }
  237. },
  238. },
  239. {
  240. label: "出库工单",
  241. prop: "outWorkOrderId",
  242. editDisabled: true,
  243. addDisplay: false,
  244. display: true,
  245. rules: [
  246. {
  247. required: true,
  248. trigger: "trigger",
  249. },
  250. ],
  251. type: "select",
  252. click: ({ value, column }) => {
  253. if (column.boxType) {
  254. dialog1.visible = true;
  255. }
  256. },
  257. change: ({ value, column }) => {
  258. if (value != form.value.materialCode) {
  259. dialog1.visible = true;
  260. }
  261. },
  262. },
  263. {
  264. label: "流转卡号",
  265. prop: "workOrderSeqNos",
  266. editDisabled: true,
  267. hide: true,
  268. disabled: seqDisabled,
  269. addDisplay: true,
  270. filterable: true,
  271. rules: [
  272. {
  273. required: true,
  274. trigger: "trigger",
  275. },
  276. ],
  277. click: ({ value, column }) => {
  278. if (column.boxType && dialog1.visible == false) {
  279. dialog2.visible = true;
  280. }
  281. },
  282. change: ({ value, column }) => {
  283. if (
  284. form.value.stockType == "1"
  285. ? form.value.inWorkOrderId && dialog1.visible == false
  286. : form.value.outWorkOrderId && dialog1.visible == false
  287. ) {
  288. dialog2.visible = true;
  289. }
  290. },
  291. },
  292. {
  293. label: "库位",
  294. prop: "location",
  295. addDisplay: true,
  296. rules: [
  297. {
  298. required: true,
  299. trigger: "trigger",
  300. },
  301. ],
  302. },
  303. // {
  304. // label: "物料类型",
  305. // prop: "taskNo",
  306. // type: "select",
  307. // search: true,
  308. // width: 90,
  309. // overHidden: true,
  310. // dicUrl: dictDataUtil.request_url + "stock_material_type",
  311. // props: {
  312. // label: "dictLabel",
  313. // value: "dictValue",
  314. // },
  315. // rules: [
  316. // {
  317. // required: true,
  318. // message: "物料类型不能为空",
  319. // trigger: "trigger",
  320. // },
  321. // ],
  322. // },
  323. // {
  324. // label: "料箱编号",
  325. // prop: "vehicleCode",
  326. // editDisabled: true,
  327. // rules: [
  328. // {
  329. // required: true,
  330. // message: "料箱编号不能为空",
  331. // trigger: "trigger",
  332. // },
  333. // ],
  334. // },
  335. // {
  336. // label: "仓库坐标",
  337. // prop: "locationNo",
  338. // editDisabled: true,
  339. // rules: [
  340. // {
  341. // required: true,
  342. // message: "仓库位置不能为空",
  343. // trigger: "trigger",
  344. // },
  345. // ],
  346. // },
  347. // {
  348. // label: "二维码",
  349. // width: 120,
  350. // overHidden: true,
  351. // prop: "batchCode",
  352. // search: true,
  353. // },
  354. // {
  355. // label: "物料名称",
  356. // prop: "materialName",
  357. // width: 130,
  358. // overHidden: true,
  359. // click: ({ value, column }) => {
  360. // if (column.boxType) {
  361. // dialog1.visible = true;
  362. // }
  363. // },
  364. // },
  365. // {
  366. // label: "数量",
  367. // prop: "num",
  368. // type: "number",
  369. // min: 0,
  370. // max: 99999,
  371. // width: 150,
  372. // overHidden: true,
  373. // formatter: (val, value, label) => {
  374. // if (val.warningMsg) {
  375. // return val.num + "(" + val.warningMsg + ")";
  376. // } else {
  377. // return val.num;
  378. // }
  379. // },
  380. // },
  381. ],
  382. });
  383. const rowStyle = ({ row, column, rowIndex }) => {
  384. if (row.warningMsg) {
  385. return {
  386. backgroundColor: "#f3d2d2",
  387. color: "#6c6a6a",
  388. };
  389. }
  390. };
  391. const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
  392. if (columnIndex === 10) {
  393. if (row.warningMsg) {
  394. return {
  395. color: "red",
  396. fontWeight: "bold",
  397. fontSize: "20",
  398. };
  399. } else {
  400. return {
  401. color: "#60fc56",
  402. fontWeight: "bold",
  403. fontSize: "20",
  404. };
  405. }
  406. }
  407. };
  408. onMounted(() => {
  409. dataList();
  410. });
  411. </script>