index.vue 7.7 KB

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