index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. </byTable>
  26. </div>
  27. <el-dialog
  28. :title="modalType == 'add' ? '添加供应商' : '编辑供应商'"
  29. v-model="dialogVisible"
  30. width="800"
  31. v-loading="loading"
  32. >
  33. <byForm
  34. :formConfig="formConfig"
  35. :formOption="formOption"
  36. v-model="formData.data"
  37. :rules="rules"
  38. ref="byform"
  39. >
  40. </byForm>
  41. <template #footer>
  42. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  43. <el-button
  44. type="primary"
  45. @click="submitForm('byform')"
  46. size="large"
  47. :loading="submitLoading"
  48. >
  49. 确 定
  50. </el-button>
  51. </template>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script setup>
  56. import { ElMessage, ElMessageBox } from "element-plus";
  57. import byTable from "@/components/byTable/index";
  58. import byForm from "@/components/byForm/index";
  59. const loading = ref(false);
  60. const submitLoading = ref(false);
  61. const sourceList = ref({
  62. data: [],
  63. pagination: {
  64. total: 3,
  65. pageNum: 1,
  66. pageSize: 10,
  67. status: "15,30",
  68. },
  69. });
  70. const dialogVisible = ref(false);
  71. const modalType = ref("add");
  72. let rules = ref({
  73. name: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
  74. });
  75. const { proxy } = getCurrentInstance();
  76. const selectConfig = reactive([
  77. {
  78. label: "状态",
  79. prop: "status",
  80. data: [
  81. {
  82. label: "待采购",
  83. value: "15",
  84. },
  85. {
  86. label: "部分采购",
  87. value: "30",
  88. },
  89. ],
  90. },
  91. {
  92. label: "收货仓库",
  93. prop: "receiptWarehouseId",
  94. data: [],
  95. },
  96. ]);
  97. const config = computed(() => {
  98. return [
  99. {
  100. type: "selection",
  101. attrs: {
  102. checkAtt: "isCheck",
  103. },
  104. },
  105. {
  106. attrs: {
  107. label: "申购单号",
  108. prop: "subscribeCode",
  109. },
  110. },
  111. {
  112. attrs: {
  113. label: "货品类型",
  114. prop: "productDefinition",
  115. },
  116. render(definition) {
  117. return definition == 1 ? "产品" : definition == 2 ? "物料" : "";
  118. },
  119. },
  120. {
  121. attrs: {
  122. label: "物品编码",
  123. prop: "productCustomCode",
  124. },
  125. },
  126. {
  127. attrs: {
  128. label: "物品名称",
  129. prop: "productName",
  130. },
  131. },
  132. {
  133. attrs: {
  134. label: "单位",
  135. prop: "productUnit",
  136. },
  137. render(unit) {
  138. return proxy.dictDataEcho(unit, productUnit.value);
  139. },
  140. },
  141. {
  142. attrs: {
  143. label: "申购数量",
  144. prop: "count",
  145. },
  146. },
  147. {
  148. attrs: {
  149. label: "已采购数量",
  150. prop: "purchaseCount",
  151. },
  152. },
  153. {
  154. attrs: {
  155. label: "收货仓库",
  156. prop: "receiptWarehouseName",
  157. width: 130,
  158. },
  159. },
  160. {
  161. attrs: {
  162. label: "要求到货时间",
  163. prop: "planArrivalTime",
  164. width: 130,
  165. },
  166. },
  167. {
  168. attrs: {
  169. label: "采购状态",
  170. prop: "status",
  171. },
  172. render(status) {
  173. return status == 15 ? "待采购" : status == 20 ? "已采购" : "部分采购";
  174. },
  175. },
  176. {
  177. attrs: {
  178. label: "申购人",
  179. prop: "subcribeName",
  180. },
  181. },
  182. {
  183. attrs: {
  184. label: "申购时间",
  185. prop: "subcribeTime",
  186. width: 155,
  187. },
  188. },
  189. {
  190. attrs: {
  191. label: "操作",
  192. width: "80",
  193. align: "right",
  194. },
  195. renderHTML(row) {
  196. return [
  197. {
  198. attrs: {
  199. label: "采购",
  200. type: "primary",
  201. text: true,
  202. },
  203. el: "button",
  204. click() {
  205. selectDataOne.value = [row];
  206. start(10);
  207. },
  208. },
  209. ];
  210. },
  211. },
  212. ];
  213. });
  214. const formData = reactive({
  215. data: {
  216. type: "1",
  217. },
  218. });
  219. const formOption = reactive({
  220. inline: true,
  221. labelWidth: 100,
  222. itemWidth: 100,
  223. rules: [],
  224. });
  225. const byform = ref(null);
  226. const formConfig = computed(() => {
  227. return [];
  228. });
  229. const getList = async (req) => {
  230. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  231. loading.value = true;
  232. proxy
  233. .post("/subscribeDetail/pageByWdly", sourceList.value.pagination)
  234. .then((message) => {
  235. message.rows.forEach((x) => {
  236. if (x.status <= 30) {
  237. x.isCheck = true;
  238. } else {
  239. x.isCheck = false;
  240. }
  241. });
  242. sourceList.value.data = message.rows.map((x) => ({
  243. ...x,
  244. ...JSON.parse(x.victoriatouristJson),
  245. }));
  246. sourceList.value.pagination.total = message.total;
  247. setTimeout(() => {
  248. loading.value = false;
  249. }, 200);
  250. });
  251. };
  252. const submitForm = () => {
  253. byform.value.handleSubmit((valid) => {
  254. formData.data.fileList = fileList.value;
  255. submitLoading.value = true;
  256. proxy.post("/productionProcesses/" + modalType.value, formData.data).then(
  257. (res) => {
  258. ElMessage({
  259. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  260. type: "success",
  261. });
  262. fileList.value = [];
  263. dialogVisible.value = false;
  264. submitLoading.value = false;
  265. getList();
  266. },
  267. (err) => {
  268. console.log(err, "aswwwww");
  269. submitLoading.value = false;
  270. }
  271. );
  272. });
  273. };
  274. const selectData = ref([]);
  275. const selectDataOne = ref([]);
  276. const selectRow = (data) => {
  277. selectData.value = data;
  278. };
  279. watch(selectData, (newVal, oldVal) => {
  280. if (newVal.length == 0) {
  281. sourceList.value.data.forEach((x) => {
  282. if (x.status <= 30) {
  283. x.isCheck = true;
  284. } else {
  285. x.isCheck = false;
  286. }
  287. });
  288. } else if (newVal.length == 1) {
  289. const current = newVal[0];
  290. sourceList.value.data.forEach((x) => {
  291. if (x.receiptWarehouseId !== current.receiptWarehouseId) {
  292. x.isCheck = false;
  293. }
  294. });
  295. }
  296. });
  297. const start = (type) => {
  298. modalType.value = "add";
  299. let ids = [];
  300. let row = {};
  301. if (type === 10) {
  302. row = selectDataOne.value[0];
  303. ids = selectDataOne.value.map((x) => x.id).join();
  304. } else if (type === 20) {
  305. ids = selectData.value.map((x) => x.id).join();
  306. row = selectData.value[0];
  307. }
  308. proxy.$router.replace({
  309. path: "/platform_manage/process/processApproval",
  310. query: {
  311. flowKey: "wdly_purchase",
  312. ids,
  313. flowName: "采购申请",
  314. },
  315. });
  316. };
  317. const warehouseList = ref([]);
  318. const productUnit = ref([]);
  319. const getDict = () => {
  320. proxy.getDict(["unit"]).then((res) => {
  321. productUnit.value = res["unit"];
  322. });
  323. proxy
  324. .post("/warehouse/page", {
  325. pageNum: 1,
  326. pageSize: 999,
  327. })
  328. .then((message) => {
  329. warehouseList.value = message.rows;
  330. selectConfig[1].data = message.rows.map((x) => ({
  331. label: x.name,
  332. value: x.id,
  333. }));
  334. });
  335. };
  336. getDict();
  337. getList();
  338. </script>
  339. <style lang="scss" scoped>
  340. .tenant {
  341. padding: 20px;
  342. }
  343. :deep(.el-table__header-wrapper .el-checkbox) {
  344. display: none;
  345. }
  346. </style>