index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <el-card class="box-card">
  3. <byTable
  4. :source="sourceList.data"
  5. :pagination="sourceList.pagination"
  6. :config="config"
  7. :loading="loading"
  8. :searchConfig="searchConfig"
  9. highlight-current-row
  10. :action-list="[
  11. {
  12. text: '同步万里牛售后单',
  13. action: () => clickSynchronousOrder(),
  14. loading: btnLoading,
  15. },
  16. ]"
  17. @get-list="getList"
  18. @clickReset="clickReset"
  19. :spanMethod="spanMethod"
  20. :borderStatus="true">
  21. </byTable>
  22. <el-dialog title="质检" v-if="openQualityTesting" v-model="openQualityTesting" width="500px">
  23. <el-form :model="rowData" ref="submit" :rules="rules" v-loading="loadingQualityTesting">
  24. <div style="margin: 10px 0; font-weight: 700; font-size: 18px; color: black">请根据质检结果选择,此裸垫是否可二次销售</div>
  25. <template v-if="rowData.orderExchangeDetailList && rowData.orderExchangeDetailList.length > 0">
  26. <div v-for="(item, index) in rowData.orderExchangeDetailList" :key="index" style="margin-top: 20px">
  27. <div style="margin-bottom: 10px">SKU品号:{{ item.skuSpecCode }}</div>
  28. <el-form-item
  29. label="质检通过数量"
  30. :prop="'orderExchangeDetailList.' + index + '.checkPassesQuantity'"
  31. :rules="rules.checkPassesQuantity"
  32. :inline-message="true">
  33. <el-input-number
  34. onmousewheel="return false;"
  35. v-model="item.checkPassesQuantity"
  36. placeholder="数量"
  37. style="width: 100%"
  38. :controls="false"
  39. :min="0"
  40. :precision="0" />
  41. </el-form-item>
  42. </div>
  43. </template>
  44. </el-form>
  45. <template #footer>
  46. <el-button @click="openQualityTesting = false" size="large" v-preReClick>取 消</el-button>
  47. <el-button type="primary" @click="clickSubmit()" size="large" v-preReClick>质检完成</el-button>
  48. </template>
  49. </el-dialog>
  50. </el-card>
  51. </template>
  52. <script setup>
  53. import byTable from "/src/components/byTable/index";
  54. import { ElMessage } from "element-plus";
  55. const { proxy } = getCurrentInstance();
  56. const departmentList = ref([]);
  57. const sourceList = ref({
  58. data: [],
  59. pagination: {
  60. total: 0,
  61. pageNum: 1,
  62. pageSize: 10,
  63. code: "",
  64. orderCode: "",
  65. orderWlnCode: "",
  66. departmentId: "",
  67. status: 0,
  68. },
  69. });
  70. const loading = ref(false);
  71. const status = ref([
  72. {
  73. dictKey: 0,
  74. dictValue: "待质检",
  75. },
  76. {
  77. dictKey: 1,
  78. dictValue: "已质检入库",
  79. },
  80. ]);
  81. const searchConfig = computed(() => {
  82. return [
  83. {
  84. type: "input",
  85. prop: "code",
  86. label: "售后单号",
  87. },
  88. {
  89. type: "input",
  90. prop: "orderCode",
  91. label: "订单号",
  92. },
  93. {
  94. type: "input",
  95. prop: "orderWlnCode",
  96. label: "E10单号",
  97. },
  98. {
  99. type: "select",
  100. prop: "departmentId",
  101. data: departmentList.value,
  102. label: "事业部",
  103. },
  104. {
  105. type: "select",
  106. prop: "status",
  107. data: status.value,
  108. label: "质检状态",
  109. },
  110. ];
  111. });
  112. const config = computed(() => {
  113. return [
  114. {
  115. attrs: {
  116. label: "售后库单号",
  117. prop: "code",
  118. },
  119. },
  120. {
  121. attrs: {
  122. label: "售后订单",
  123. prop: "orderCode",
  124. },
  125. },
  126. {
  127. attrs: {
  128. label: "E10单号",
  129. prop: "orderWlnCode",
  130. },
  131. },
  132. {
  133. attrs: {
  134. label: "退货事业部",
  135. prop: "departmentName",
  136. },
  137. },
  138. {
  139. attrs: {
  140. label: "SKU品号",
  141. prop: "skuSpecCode",
  142. },
  143. },
  144. {
  145. attrs: {
  146. label: "数量",
  147. prop: "quantity",
  148. width: 100,
  149. },
  150. },
  151. {
  152. attrs: {
  153. label: "退货金额",
  154. prop: "returnAmount",
  155. width: 120,
  156. },
  157. },
  158. {
  159. attrs: {
  160. label: "售后时间",
  161. prop: "createTime",
  162. align: "center",
  163. width: 160,
  164. },
  165. },
  166. {
  167. attrs: {
  168. label: "质检状态",
  169. prop: "status",
  170. width: 120,
  171. },
  172. render(val) {
  173. return proxy.dictKeyValue(val, status.value);
  174. },
  175. },
  176. {
  177. attrs: {
  178. label: "操作人",
  179. prop: "createUserName",
  180. },
  181. },
  182. {
  183. attrs: {
  184. label: "操作",
  185. width: 140,
  186. align: "center",
  187. fixed: "right",
  188. },
  189. renderHTML(row) {
  190. return [
  191. row.status === 0
  192. ? {
  193. attrs: {
  194. label: "质检",
  195. type: "primary",
  196. text: true,
  197. },
  198. el: "button",
  199. click() {
  200. clickQualityTesting(row);
  201. },
  202. }
  203. : {},
  204. {
  205. attrs: {
  206. label: "查看详情",
  207. type: "primary",
  208. text: true,
  209. },
  210. el: "button",
  211. click() {
  212. clickDetail(row);
  213. },
  214. },
  215. ];
  216. },
  217. },
  218. ];
  219. });
  220. const getDemandData = () => {
  221. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  222. if (res.rows && res.rows.length > 0) {
  223. departmentList.value = res.rows.map((item) => {
  224. return {
  225. dictKey: item.id,
  226. dictValue: item.name,
  227. };
  228. });
  229. }
  230. });
  231. };
  232. getDemandData();
  233. const mergeRow = (list) => {
  234. for (let field in list[0]) {
  235. let k = 0;
  236. let i = 0;
  237. while (k < list.length) {
  238. list[k][field + "Span"] = 1;
  239. list[k][field + "Dis"] = false;
  240. for (i = k + 1; i <= list.length - 1; i++) {
  241. if (list[k][field] === list[i][field] && list[k].id === list[i].id) {
  242. list[k][field + "Span"]++;
  243. list[k][field + "Dis"] = false;
  244. list[i][field + "Span"] = 1;
  245. list[i][field + "Dis"] = true;
  246. } else {
  247. break;
  248. }
  249. }
  250. k = i;
  251. }
  252. }
  253. return list;
  254. };
  255. const getList = async (req, status) => {
  256. if (status) {
  257. sourceList.value.pagination = {
  258. pageNum: sourceList.value.pagination.pageNum,
  259. pageSize: sourceList.value.pagination.pageSize,
  260. };
  261. } else {
  262. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  263. }
  264. loading.value = true;
  265. proxy.post("/orderExchange/page", sourceList.value.pagination).then((res) => {
  266. let list = [];
  267. for (let i = 0; i < res.rows.length; i++) {
  268. if (res.rows[i].orderExchangeDetailList && res.rows[i].orderExchangeDetailList.length > 0) {
  269. for (let j = 0; j < res.rows[i].orderExchangeDetailList.length; j++) {
  270. list.push({
  271. id: res.rows[i].id,
  272. code: res.rows[i].code,
  273. orderCode: res.rows[i].orderCode,
  274. orderWlnCode: res.rows[i].orderWlnCode,
  275. departmentName: res.rows[i].departmentName,
  276. skuSpecCode: res.rows[i].orderExchangeDetailList[j].skuSpecCode,
  277. quantity: res.rows[i].orderExchangeDetailList[j].quantity,
  278. returnAmount: res.rows[i].orderExchangeDetailList[j].returnAmount,
  279. createTime: res.rows[i].createTime,
  280. createUserName: res.rows[i].createUserName,
  281. status: res.rows[i].status,
  282. orderExchangeDetailList: res.rows[i].orderExchangeDetailList,
  283. });
  284. }
  285. }
  286. }
  287. sourceList.value.data = Object.freeze(mergeRow(list));
  288. sourceList.value.pagination.total = res.total;
  289. setTimeout(() => {
  290. loading.value = false;
  291. }, 200);
  292. });
  293. };
  294. getList();
  295. const clickReset = () => {
  296. getList("", true);
  297. };
  298. const clickDetail = (row) => {
  299. proxy.$router.replace({
  300. path: "/order/after-sale/initiate",
  301. query: {
  302. id: row.id,
  303. random: proxy.random(),
  304. },
  305. });
  306. };
  307. const spanMethod = ({ rowIndex, columnIndex }) => {
  308. if ([0, 1, 2, 3, 7, 8, 9].includes(columnIndex)) {
  309. let spanName = ["code", "orderCode", "orderWlnCode", "departmentName", "", "", "", "createTime", "createUserName", "id"];
  310. const row1 = sourceList.value.data[rowIndex][spanName[columnIndex] + "Span"];
  311. const colspan = sourceList.value.data[rowIndex][spanName[columnIndex] + "Dis"] ? 0 : 1;
  312. const rowspan = colspan === 1 ? row1 : 0;
  313. return {
  314. rowspan: rowspan,
  315. colspan: colspan,
  316. };
  317. }
  318. };
  319. const rowData = ref({});
  320. const openQualityTesting = ref(false);
  321. const loadingQualityTesting = ref(false);
  322. const rules = ref({
  323. checkPassesQuantity: [{ required: true, message: "请输入质检通过数量", trigger: "blur" }],
  324. });
  325. const clickQualityTesting = (item) => {
  326. rowData.value = proxy.deepClone(item);
  327. if (rowData.value.orderExchangeDetailList && rowData.value.orderExchangeDetailList.length > 0) {
  328. rowData.value.orderExchangeDetailList = rowData.value.orderExchangeDetailList.map((row) => {
  329. return {
  330. ...row,
  331. checkPassesQuantity: row.quantity,
  332. };
  333. });
  334. }
  335. loadingQualityTesting.value = false;
  336. openQualityTesting.value = true;
  337. };
  338. const clickSubmit = () => {
  339. proxy.$refs.submit.validate((valid) => {
  340. if (valid) {
  341. loadingQualityTesting.value = true;
  342. proxy.post("/orderExchange/orderExchangeCheck", rowData.value).then(
  343. () => {
  344. ElMessage({ message: "质检完成", type: "success" });
  345. openQualityTesting.value = false;
  346. getList();
  347. },
  348. (err) => {
  349. console.log(err);
  350. loadingQualityTesting.value = false;
  351. }
  352. );
  353. }
  354. });
  355. };
  356. const btnLoading = ref(false);
  357. const clickSynchronousOrder = () => {
  358. btnLoading.value = true;
  359. proxy.post("/orderHandle/resynchronizationReturnOrder", {}).then(
  360. () => {
  361. ElMessage.success("同步完成成功");
  362. btnLoading.value = false;
  363. getList();
  364. },
  365. (err) => {
  366. ElMessage.error(`同步失败: ${err} !`);
  367. btnLoading.value = false;
  368. }
  369. );
  370. };
  371. </script>
  372. <style lang="scss" scoped>
  373. ::v-deep(.el-input-number .el-input__inner) {
  374. text-align: left;
  375. }
  376. </style>