index.vue 11 KB

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