index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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: (data) => selectRow(data, 'row'),
  15. 'select-all': (data) => selectAll(data, 'all'),
  16. 'sort-change': sortChange,
  17. }"
  18. :action-list="[
  19. {
  20. text: '采购',
  21. disabled: selectData.length === 0 && selectAllData.length === 0,
  22. action: () => start(20),
  23. },
  24. ]"
  25. @get-list="getList"
  26. >
  27. <template #pic="{ item }">
  28. <div v-if="item.fileList.length > 0">
  29. <img
  30. :src="item.fileList[0].fileUrl"
  31. class="pic"
  32. @click="handleClickFile(item.fileList[0])"
  33. />
  34. </div>
  35. <div v-else></div>
  36. </template>
  37. </byTable>
  38. </div>
  39. </div>
  40. </template>
  41. <script setup>
  42. import { ElMessage, ElMessageBox } from "element-plus";
  43. import byTable from "@/components/byTable/index";
  44. import byForm from "@/components/byForm/index";
  45. const loading = ref(false);
  46. const submitLoading = ref(false);
  47. const sourceList = ref({
  48. data: [],
  49. pagination: {
  50. total: 3,
  51. pageNum: 1,
  52. pageSize: 10,
  53. status: "15,30",
  54. subscribeTimeSort: "",
  55. productNameSort: "",
  56. },
  57. });
  58. const dialogVisible = ref(false);
  59. let rules = ref({
  60. name: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
  61. });
  62. const { proxy } = getCurrentInstance();
  63. const selectConfig = reactive([
  64. {
  65. label: "状态",
  66. prop: "status",
  67. data: [
  68. {
  69. label: "待采购",
  70. value: "15",
  71. },
  72. {
  73. label: "部分采购",
  74. value: "30",
  75. },
  76. ],
  77. },
  78. {
  79. label: "收货仓库",
  80. prop: "receiptWarehouseId",
  81. data: [],
  82. },
  83. {
  84. label: "产品归属部门",
  85. prop: "deptId",
  86. data: [],
  87. },
  88. {
  89. label: "提交状态",
  90. prop: "subStatus",
  91. data: [
  92. {
  93. label: "未提交",
  94. value: "1",
  95. },
  96. {
  97. label: "部分提交",
  98. value: "2",
  99. },
  100. {
  101. label: "已提交",
  102. value: "3",
  103. },
  104. ],
  105. },
  106. ]);
  107. const config = computed(() => {
  108. return [
  109. {
  110. type: "selection",
  111. attrs: {
  112. checkAtt: "isCheck",
  113. },
  114. },
  115. {
  116. attrs: {
  117. label: "申购单号",
  118. prop: "subscribeCode",
  119. width: 150,
  120. },
  121. },
  122. {
  123. attrs: {
  124. label: "货品类型",
  125. prop: "productDefinition",
  126. width: 100,
  127. },
  128. render(definition) {
  129. return definition == 1 ? "产品" : definition == 2 ? "物料" : "";
  130. },
  131. },
  132. {
  133. attrs: {
  134. label: "物品编码",
  135. prop: "productCustomCode",
  136. width: 150,
  137. },
  138. },
  139. {
  140. attrs: {
  141. label: "物品名称",
  142. prop: "productName",
  143. "min-width": 150,
  144. sortable: "custom",
  145. },
  146. },
  147. {
  148. attrs: {
  149. label: "产品图片",
  150. slot: "pic",
  151. width: 80,
  152. },
  153. },
  154. {
  155. attrs: {
  156. label: "规格",
  157. prop: "productSpec",
  158. // width: 120,
  159. },
  160. },
  161. {
  162. attrs: {
  163. label: "单位",
  164. prop: "productUnit",
  165. width: 80,
  166. },
  167. render(unit) {
  168. return proxy.dictDataEcho(unit, productUnit.value);
  169. },
  170. },
  171. {
  172. attrs: {
  173. label: "申购数量",
  174. prop: "count",
  175. width: 100,
  176. },
  177. },
  178. {
  179. attrs: {
  180. label: "已采购数量",
  181. prop: "purchaseCount",
  182. width: 100,
  183. },
  184. },
  185. {
  186. attrs: {
  187. label: "收货仓库",
  188. prop: "receiptWarehouseName",
  189. width: 130,
  190. },
  191. },
  192. {
  193. attrs: {
  194. label: "要求到货时间",
  195. prop: "planArrivalTime",
  196. width: 130,
  197. },
  198. },
  199. {
  200. attrs: {
  201. label: "采购状态",
  202. prop: "status",
  203. width: 100,
  204. },
  205. render(status) {
  206. return status == 15 ? "待采购" : status == 20 ? "已采购" : "部分采购";
  207. },
  208. },
  209. {
  210. attrs: {
  211. label: "申购人",
  212. prop: "subcribeName",
  213. width: 100,
  214. },
  215. },
  216. {
  217. attrs: {
  218. label: "申购时间",
  219. prop: "subcribeTime",
  220. width: 155,
  221. sortable: "custom",
  222. },
  223. },
  224. {
  225. attrs: {
  226. label: "操作",
  227. width: "80",
  228. align: "center",
  229. },
  230. renderHTML(row) {
  231. return [
  232. {
  233. attrs: {
  234. label: "采购",
  235. type: "primary",
  236. text: true,
  237. },
  238. el: "button",
  239. click() {
  240. selectDataOne.value = [row];
  241. start(10);
  242. },
  243. },
  244. ];
  245. },
  246. },
  247. ];
  248. });
  249. const formData = reactive({
  250. data: {
  251. type: "1",
  252. },
  253. });
  254. const formOption = reactive({
  255. inline: true,
  256. labelWidth: 100,
  257. itemWidth: 100,
  258. rules: [],
  259. });
  260. const byform = ref(null);
  261. const formConfig = computed(() => {
  262. return [];
  263. });
  264. const getList = async (req) => {
  265. if (req === undefined || req.status === "") {
  266. req = {
  267. ...req,
  268. neStatus: "99",
  269. status: "15,30",
  270. };
  271. }
  272. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  273. getDeptList();
  274. loading.value = true;
  275. proxy
  276. .post("/subscribeDetail/pageByWdly", sourceList.value.pagination)
  277. .then((message) => {
  278. message.rows.forEach((x) => {
  279. if (x.status <= 30) {
  280. x.isCheck = true;
  281. } else {
  282. x.isCheck = false;
  283. }
  284. });
  285. sourceList.value.data = message.rows.map((x) => ({
  286. ...x,
  287. ...JSON.parse(x.victoriatouristJson),
  288. fileList: [],
  289. }));
  290. sourceList.value.pagination.total = message.total;
  291. setTimeout(() => {
  292. loading.value = false;
  293. }, 200);
  294. const productIdList = message.rows.map((x) => x.bussinessId);
  295. // 请求文件数据并回显
  296. if (productIdList && productIdList.length > 0) {
  297. proxy
  298. .post("/fileInfo/getList", { businessIdList: productIdList })
  299. .then((fileObj) => {
  300. for (let i = 0; i < sourceList.value.data.length; i++) {
  301. const e = sourceList.value.data[i];
  302. for (const key in fileObj) {
  303. if (e.bussinessId === key) {
  304. e.fileList = fileObj[key];
  305. }
  306. }
  307. }
  308. });
  309. }
  310. });
  311. };
  312. const selectData = ref([]);
  313. const selectDataOne = ref([]);
  314. const selectAllData = ref([]);
  315. const selectType = ref("row");
  316. const selectRow = (data, type) => {
  317. selectType.value = type;
  318. selectData.value = data;
  319. };
  320. const selectAll = (data, type) => {
  321. selectType.value = type;
  322. selectAllData.value = data;
  323. };
  324. watch(selectData, (newVal, oldVal) => {
  325. if (newVal.length == 0) {
  326. sourceList.value.data.forEach((x) => {
  327. if (x.status <= 30) {
  328. x.isCheck = true;
  329. } else {
  330. x.isCheck = false;
  331. }
  332. });
  333. } else if (newVal.length == 1) {
  334. const current = newVal[0];
  335. sourceList.value.data.forEach((x) => {
  336. if (
  337. x.receiptWarehouseId !== current.receiptWarehouseId ||
  338. x.deptId !== current.deptId
  339. ) {
  340. x.isCheck = false;
  341. }
  342. });
  343. }
  344. });
  345. const start = (type) => {
  346. if (selectType.value === "all") {
  347. let row = selectAllData.value[0];
  348. let receiptWarehouseId = row.receiptWarehouseId;
  349. let deptId = row.deptId;
  350. const flagReceiptWarehouseId = selectAllData.value.every(
  351. (x) => x.receiptWarehouseId === receiptWarehouseId
  352. );
  353. const flagDeptId = selectAllData.value.every((x) => x.deptId === deptId);
  354. if (flagReceiptWarehouseId && flagDeptId) {
  355. let ids = selectAllData.value.map((x) => x.id).join();
  356. proxy.$router.replace({
  357. path: "/platform_manage/process/processApproval",
  358. query: {
  359. flowKey: "wdly_purchase",
  360. ids,
  361. flowName: "采购申请",
  362. random: proxy.random(),
  363. },
  364. });
  365. } else {
  366. return ElMessage({
  367. message: `不能采购不同仓库或不同部门的商品`,
  368. type: "info",
  369. });
  370. }
  371. } else {
  372. let ids = [];
  373. let row = {};
  374. if (type === 10) {
  375. row = selectDataOne.value[0];
  376. ids = selectDataOne.value.map((x) => x.id).join();
  377. } else if (type === 20) {
  378. ids = selectData.value.map((x) => x.id).join();
  379. row = selectData.value[0];
  380. }
  381. proxy.$router.replace({
  382. path: "/platform_manage/process/processApproval",
  383. query: {
  384. flowKey: "wdly_purchase",
  385. ids,
  386. flowName: "采购申请",
  387. random: proxy.random(),
  388. },
  389. });
  390. }
  391. };
  392. const warehouseList = ref([]);
  393. const productUnit = ref([]);
  394. const deptData = ref([]);
  395. const getDeptList = () => {
  396. proxy
  397. .post("/subscribe/getDepts", { status: sourceList.value.pagination.status })
  398. .then((res) => {
  399. deptData.value = res;
  400. selectConfig[2].data = res.map((x) => ({
  401. label: x.deptName,
  402. value: x.deptId,
  403. }));
  404. });
  405. };
  406. const getDict = () => {
  407. proxy.getDict(["unit"]).then((res) => {
  408. productUnit.value = res["unit"];
  409. });
  410. proxy
  411. .post("/warehouse/page", {
  412. pageNum: 1,
  413. pageSize: 999,
  414. })
  415. .then((message) => {
  416. warehouseList.value = message.rows;
  417. selectConfig[1].data = message.rows.map((x) => ({
  418. label: x.name,
  419. value: x.id,
  420. }));
  421. });
  422. // getDeptList();
  423. };
  424. getDict();
  425. const sortChange = ({ column, prop, order }) => {
  426. sourceList.value.pagination.subscribeTimeSort = "";
  427. sourceList.value.pagination.productNameSort = "";
  428. let type = "";
  429. if (order === "ascending") {
  430. // 升序
  431. type = "1";
  432. } else if (order === "descending") {
  433. // 降序
  434. type = "0";
  435. } else {
  436. // 默认
  437. }
  438. if (column.label === "物品名称") {
  439. sourceList.value.pagination.productNameSort = type;
  440. } else if (column.label === "申购时间") {
  441. sourceList.value.pagination.subscribeTimeSort = type;
  442. } else {
  443. sourceList.value.pagination.subscribeTimeSort = "";
  444. sourceList.value.pagination.productNameSort = "";
  445. }
  446. getList();
  447. };
  448. sortChange({
  449. column: {
  450. label: "申购时间",
  451. },
  452. order: "descending",
  453. prop: undefined,
  454. });
  455. const handleClickFile = (file) => {
  456. window.open(file.fileUrl, "_blank");
  457. };
  458. </script>
  459. <style lang="scss" scoped>
  460. .tenant {
  461. padding: 20px;
  462. }
  463. // :deep(.el-table__header-wrapper .el-checkbox) {
  464. // display: none;
  465. // }
  466. .pic {
  467. object-fit: contain;
  468. width: 50px;
  469. height: 50px;
  470. cursor: pointer;
  471. vertical-align: middle;
  472. }
  473. </style>