index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row :table-events="{
  5. select: selectRow,
  6. 'select-all': selectRow,
  7. }" :action-list="[
  8. {
  9. text: '采购',
  10. disabled: selectData.length === 0,
  11. action: () => clickPurchase(),
  12. },
  13. ]" @get-list="getList">
  14. <template #claimTime="{ item }">
  15. <div style="width: 100%">
  16. <span v-if="item.claimTime">{{ item.claimTime }}</span>
  17. <span v-else>未到账</span>
  18. </div>
  19. </template>
  20. <template #timeSpent="{ item }">
  21. <div style="width: 100%">
  22. <span>{{ getTimeSpent(item) }}</span>
  23. </div>
  24. </template>
  25. </byTable>
  26. </div>
  27. <el-dialog title="交接单" v-if="openAllFile" v-model="openAllFile" width="600">
  28. <byForm :formConfig="formConfig" :formOption="formOption" v-model="rowData" ref="fileState">
  29. <template #file>
  30. <div>
  31. <div v-for="(file, index) in rowData.fileList" :key="index" style="padding: 4px 0">
  32. <a style="color: #409eff; cursor: pointer" @click="openFile(file.fileUrl)">{{ file.fileName }}</a>
  33. </div>
  34. </div>
  35. </template>
  36. <template #indication>
  37. <div>
  38. <div v-for="(file, index) in rowData.packageFileList" :key="index" style="padding: 4px 0">
  39. <a style="color: #409eff; cursor: pointer" @click="openFile(file.fileUrl)">{{ file.fileName }}</a>
  40. </div>
  41. </div>
  42. </template>
  43. </byForm>
  44. <template #footer>
  45. <el-button @click="openAllFile = false" size="default">关 闭</el-button>
  46. </template>
  47. </el-dialog>
  48. </div>
  49. </template>
  50. <script setup>
  51. import { computed, ref } from "vue";
  52. import byTable from "@/components/byTable/index";
  53. import byForm from "@/components/byForm/index";
  54. import moment from "moment";
  55. const { proxy } = getCurrentInstance();
  56. const sourceList = ref({
  57. data: [],
  58. pagination: {
  59. total: 0,
  60. pageNum: 1,
  61. pageSize: 10,
  62. keyword: "",
  63. },
  64. });
  65. const loading = ref(false);
  66. const config = computed(() => {
  67. return [
  68. {
  69. type: "selection",
  70. attrs: {
  71. checkAtt: "isCheck",
  72. },
  73. },
  74. {
  75. attrs: {
  76. label: "外销合同编号",
  77. prop: "contractCode",
  78. width: 180,
  79. },
  80. },
  81. {
  82. attrs: {
  83. label: "合同到账时间",
  84. slot: "claimTime",
  85. width: 160,
  86. },
  87. },
  88. {
  89. attrs: {
  90. label: "业务员",
  91. prop: "userName",
  92. width: 140,
  93. },
  94. },
  95. // {
  96. // attrs: {
  97. // label: "版本号",
  98. // prop: "contractVersion",
  99. // width: 100,
  100. // },
  101. // },
  102. {
  103. attrs: {
  104. label: "产品编码",
  105. prop: "productCode",
  106. width: 160,
  107. },
  108. },
  109. {
  110. attrs: {
  111. label: "产品名称",
  112. prop: "productName",
  113. "min-width": 220,
  114. },
  115. },
  116. // {
  117. // attrs: {
  118. // label: "单位",
  119. // prop: "productUnit",
  120. // width: 140,
  121. // },
  122. // },
  123. {
  124. attrs: {
  125. label: "待采购数量",
  126. prop: "expendQuantity",
  127. width: 140,
  128. },
  129. },
  130. {
  131. attrs: {
  132. label: "已耗时",
  133. slot: "timeSpent",
  134. width: 140,
  135. },
  136. },
  137. {
  138. attrs: {
  139. label: "交接单",
  140. width: 80,
  141. align: "center",
  142. fixed: "right",
  143. },
  144. renderHTML(row) {
  145. return [
  146. {
  147. attrs: {
  148. label: "查看",
  149. type: "primary",
  150. text: true,
  151. },
  152. el: "button",
  153. click() {
  154. checkTheTransferSlip(row);
  155. },
  156. },
  157. ];
  158. },
  159. },
  160. {
  161. attrs: {
  162. label: "操作",
  163. width: 80,
  164. align: "center",
  165. fixed: "right",
  166. },
  167. renderHTML(row) {
  168. return [
  169. {
  170. attrs: {
  171. label: "采购",
  172. type: "primary",
  173. text: true,
  174. },
  175. el: "button",
  176. click() {
  177. clickPurchase(row);
  178. },
  179. },
  180. ];
  181. },
  182. },
  183. ];
  184. });
  185. const getList = async (req) => {
  186. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  187. loading.value = true;
  188. proxy
  189. .post("/delivery/contractHandoverPage", sourceList.value.pagination)
  190. .then((res) => {
  191. sourceList.value.data = res.rows.map((x) => ({ ...x, isCheck: true }));
  192. sourceList.value.pagination.total = res.total;
  193. setTimeout(() => {
  194. loading.value = false;
  195. }, 200);
  196. });
  197. };
  198. getList();
  199. const clickPurchase = (row) => {
  200. let ids = "";
  201. let dataResourceId = "";
  202. if (row && row.id) {
  203. ids = row.id;
  204. dataResourceId = row.contractId;
  205. } else {
  206. ids = selectData.value
  207. .map((item) => {
  208. return item.id;
  209. })
  210. .join(",");
  211. dataResourceId = selectData.value[0].contractId;
  212. }
  213. proxy.$router.replace({
  214. path: "/platform_manage/process/processApproval",
  215. query: {
  216. flowKey: "ehsd_purchase_flow",
  217. flowName: "销售订单采购审批",
  218. random: proxy.random(),
  219. ids: ids,
  220. type: 1,
  221. submitType: "10",
  222. dataResourceId,
  223. },
  224. });
  225. };
  226. const selectData = ref([]);
  227. const selectRow = (data) => {
  228. selectData.value = data;
  229. };
  230. // 监听选中的值,并动态更新是否可选中
  231. watch(selectData, (newVal, oldVal) => {
  232. if (newVal.length == 0) {
  233. sourceList.value.data.forEach((x) => {
  234. x.isCheck = true;
  235. });
  236. } else if (newVal.length == 1) {
  237. const current = newVal[0];
  238. sourceList.value.data.forEach((x) => {
  239. if (x.contractId !== current.contractId) {
  240. x.isCheck = false;
  241. }
  242. });
  243. }
  244. });
  245. const rowData = ref({
  246. fileList: [],
  247. packageFileList: [],
  248. });
  249. const openAllFile = ref(false);
  250. const checkTheTransferSlip = (item) => {
  251. rowData.value = item;
  252. rowData.value.fileList = [];
  253. rowData.value.packageFileList = [];
  254. openAllFile.value = true;
  255. proxy
  256. .post("/fileInfo/getList", {
  257. businessIdList: [item.contractId],
  258. fileType: 1,
  259. })
  260. .then((fileObj) => {
  261. rowData.value.fileList = fileObj[item.contractId] || [];
  262. });
  263. proxy
  264. .post("/fileInfo/getList", {
  265. businessIdList: [item.contractId],
  266. fileType: 2,
  267. })
  268. .then((fileObj) => {
  269. rowData.value.packageFileList = fileObj[item.contractId] || [];
  270. });
  271. };
  272. const openFile = (path) => {
  273. window.open(path, "_blank");
  274. };
  275. const formOption = reactive({
  276. inline: true,
  277. labelWidth: 100,
  278. itemWidth: 100,
  279. rules: [],
  280. });
  281. const fileState = ref(null);
  282. const formConfig = computed(() => {
  283. return [
  284. {
  285. type: "input",
  286. prop: "contractCode",
  287. label: "合同编号",
  288. itemType: "text",
  289. disabled: true,
  290. },
  291. {
  292. type: "input",
  293. prop: "buyCorporationName",
  294. label: "客户名称",
  295. itemType: "text",
  296. disabled: true,
  297. },
  298. {
  299. type: "slot",
  300. slotName: "file",
  301. label: "交接单",
  302. },
  303. {
  304. type: "slot",
  305. slotName: "indication",
  306. label: "包装指示",
  307. },
  308. ];
  309. });
  310. const getTimeSpent = (item) => {
  311. let text = "";
  312. if (item.sampleTime && item.updateTime) {
  313. let data = { days: 0, hours: 0, minutes: 0, seconds: 0 };
  314. if (proxy.compareTime(item.sampleTime, item.updateTime)) {
  315. data = proxy.timeInterval(
  316. item.sampleTime,
  317. moment().format("yyyy-MM-DD HH:mm:ss")
  318. );
  319. } else {
  320. data = proxy.timeInterval(
  321. item.updateTime,
  322. moment().format("yyyy-MM-DD HH:mm:ss")
  323. );
  324. }
  325. if (data.days) {
  326. text = data.days + "天" + data.hours + "小时" + data.minutes + "分";
  327. } else {
  328. if (data.hours) {
  329. text = data.hours + "小时" + data.minutes + "分";
  330. } else {
  331. text = data.minutes + "分";
  332. }
  333. }
  334. }
  335. return text;
  336. };
  337. </script>
  338. <style lang="scss" scoped>
  339. .tenant {
  340. padding: 20px;
  341. }
  342. :deep(.el-table__header-wrapper .el-checkbox) {
  343. display: none;
  344. }
  345. ::v-deep(.el-input-number .el-input__inner) {
  346. text-align: left;
  347. }
  348. .baseRow {
  349. min-height: 24px;
  350. border-top: 1px solid black;
  351. border-left: 1px solid black;
  352. }
  353. .contentRow {
  354. border-right: 1px solid black;
  355. line-height: 24px;
  356. padding-left: 4px;
  357. }
  358. </style>