index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <div class="pagePadding">
  3. <div
  4. class="tableBox"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. >
  7. <ex-table
  8. ref="multipleTable"
  9. v-loading="loading"
  10. :table="table"
  11. :data="tableData"
  12. :columns="columns"
  13. :page="pageInfo"
  14. :size="size"
  15. @page-curr-change="handlePageChange"
  16. @page-size-change="handleSizeChange"
  17. @screen-reset="
  18. pageInfo.curr = 1;
  19. parmValue.page = 1;
  20. searchList();
  21. "
  22. @screen-submit="
  23. pageInfo.curr = 1;
  24. parmValue.page = 1;
  25. searchList();
  26. "
  27. @selection="selection_change"
  28. ><template #table-header="{}">
  29. <div class="searchBox" style="width: 100%">
  30. <el-row style="margin: 0 0 0 80px; padding: 0 0 10px 0">
  31. <el-col :span="4" style="width: 150px">
  32. <el-select
  33. @change="
  34. pageInfo.curr = 1;
  35. parmValue.page = 1;
  36. searchList();
  37. "
  38. :size="searchSize"
  39. v-model="parmValue.status"
  40. style="width: 100%"
  41. placeholder="状态筛选"
  42. >
  43. <el-option
  44. v-for="item in statusArr"
  45. :key="item.value"
  46. :label="item.label"
  47. :value="item.value"
  48. >
  49. </el-option>
  50. </el-select>
  51. </el-col>
  52. <el-col :span="7" style="width: 352px; padding: 0 0 0 10px">
  53. <periodDatePickerActive
  54. :start="parmValue.platform_time_start"
  55. :end="parmValue.platform_time_end"
  56. :placeholder="'下单'"
  57. :width="'160px'"
  58. :size="searchSize"
  59. @timeReturned="platformTime"
  60. />
  61. </el-col>
  62. <el-col
  63. :span="2"
  64. class="fr"
  65. style="width: 66px; padding: 0 0 0 10px"
  66. >
  67. <el-button
  68. size="mini"
  69. type="primary"
  70. class="btn"
  71. @click="resetF5"
  72. >刷新</el-button
  73. >
  74. </el-col>
  75. <el-col
  76. :span="2"
  77. class="fr"
  78. style="width: 130px; padding: 0 0 0 10px"
  79. v-if="
  80. powers &&
  81. powers.length > 0 &&
  82. powers.some((item) => item == '013')
  83. "
  84. >
  85. <el-button
  86. type="primary"
  87. icon="el-icon-download"
  88. class="btn"
  89. size="mini"
  90. ><a href="./static/C端订单导入模板.xlsx"
  91. >下载导入模板</a
  92. ></el-button
  93. >
  94. </el-col>
  95. </el-row>
  96. <el-row style="padding: 0 0 10px 0">
  97. <el-col :span="6" style="width: 230px">
  98. <search-terrace
  99. :value="parmValue.platform_id"
  100. :disabled="false"
  101. :size="'mini'"
  102. :isDetail="false"
  103. :is_show="'0'"
  104. :placeholder="'导入目标平台'"
  105. @searchChange="platform_codesearchChange"
  106. /></el-col>
  107. <el-col :span="8" style="width: 352px; padding: 0 0 0 10px">
  108. <periodDatePickerActive
  109. :start="parmValue.addtime_start"
  110. :end="parmValue.addtime_end"
  111. :placeholder="'导入'"
  112. :width="'160px'"
  113. :size="searchSize"
  114. @timeReturned="addtime"
  115. />
  116. </el-col>
  117. <el-col
  118. :span="2"
  119. class="fr"
  120. style="width: 66px; padding: 0 0 0 10px"
  121. >
  122. <el-button type="warning" class="btn" @click="reset" size="mini"
  123. >重置</el-button
  124. >
  125. </el-col>
  126. <el-col
  127. :span="2"
  128. class="fr"
  129. style="width: 130px; padding: 0 0 0 10px"
  130. v-if="
  131. powers &&
  132. powers.length > 0 &&
  133. powers.some((item) => item == '085')
  134. "
  135. >
  136. <el-button
  137. size="mini"
  138. type="primary"
  139. icon="el-icon-share"
  140. class="btn"
  141. @click="selectStock"
  142. >批量关联库存</el-button
  143. >
  144. </el-col>
  145. </el-row>
  146. <el-row>
  147. <el-col :span="10" style="width: 400px">
  148. <el-input
  149. v-model="inputValue"
  150. :size="searchSize"
  151. @blur="
  152. pageInfo.curr = 1;
  153. parmValue.page = 1;
  154. searchList();
  155. "
  156. placeholder="关键字"
  157. >
  158. <el-select
  159. style="width: 120px"
  160. @change="
  161. pageInfo.curr = 1;
  162. parmValue.page = 1;
  163. searchList();
  164. "
  165. slot="prepend"
  166. :size="searchSize"
  167. v-model="selectValue"
  168. >
  169. <el-option
  170. v-for="item in selectValueArr"
  171. :key="item.value"
  172. :label="item.label"
  173. :value="item.value"
  174. >
  175. </el-option>
  176. </el-select>
  177. </el-input>
  178. </el-col>
  179. <el-col
  180. :span="2"
  181. class="fr"
  182. style="width: 66px; padding: 0 0 0 10px"
  183. v-if="powers.some((item) => item == '006')"
  184. >
  185. <el-button
  186. size="mini"
  187. type="danger"
  188. class="btn"
  189. @click="batchDel"
  190. >删除</el-button
  191. >
  192. </el-col>
  193. <el-col
  194. :span="2"
  195. class="fr"
  196. style="width: 130px; padding: 0 0 0 10px"
  197. v-if="
  198. powers &&
  199. powers.length > 0 &&
  200. powers.some((item) => item == '086')
  201. "
  202. >
  203. <el-button
  204. class="btn entry"
  205. @click="entry"
  206. size="mini"
  207. icon="el-icon-upload"
  208. type="success"
  209. >平台订单导入</el-button
  210. >
  211. </el-col>
  212. </el-row>
  213. </div>
  214. </template>
  215. <template #statusTxt="{ scope }">
  216. <el-tag
  217. :size="'mini'"
  218. :type="statusActiveTag(scope.row.status)"
  219. style="margin: auto"
  220. >{{ statusActive(scope.row.status) }}</el-tag
  221. >
  222. </template>
  223. <template #operation="{ scope }">
  224. <el-tooltip
  225. v-if="
  226. powers.some((item) => item == '007') && scope.row.status !== '5'
  227. "
  228. effect="dark"
  229. content="详情"
  230. placement="top"
  231. >
  232. <i
  233. class="el-icon-view tb-icon"
  234. @click="getRouter('orderConfirm', scope.row.id, scope.row.status)"
  235. ></i>
  236. </el-tooltip>
  237. <el-tooltip
  238. v-if="
  239. powers.some((item) => item == '006') &&
  240. (scope.row.status === '2' || scope.row.status === '4')
  241. "
  242. effect="dark"
  243. content="删除"
  244. placement="top"
  245. >
  246. <i
  247. class="el-icon-delete tb-icon"
  248. @click="deleteItem([scope.row.id])"
  249. ></i>
  250. </el-tooltip>
  251. </template>
  252. </ex-table>
  253. </div>
  254. <div v-else>
  255. <no-auth></no-auth>
  256. </div>
  257. </div>
  258. </template>
  259. <script>
  260. import { listCol } from "./columns";
  261. import { mapGetters } from "vuex";
  262. import asyncRequest from "@/apis/service/orderEntry/orderEnter";
  263. import mixinPage from "@/mixins/elPaginationHandle";
  264. import resToken from "@/mixins/resToken";
  265. import periodDatePickerActive from "./period-date-picker/main.vue";
  266. export default {
  267. mixins: [mixinPage, resToken],
  268. components: {
  269. periodDatePickerActive,
  270. },
  271. data() {
  272. return {
  273. // centerDialogVisible: false,
  274. loading: true,
  275. //竞价类型
  276. statusArr: [
  277. { value: "1", label: "系统验证数据中" },
  278. { value: "2", label: "待确认订单信息" },
  279. { value: "3", label: "待处理(待扣减库存)" },
  280. { value: "4", label: "库存不足" },
  281. { value: "5", label: "订单录入成功" },
  282. ],
  283. //多筛选select
  284. selectValueArr: [
  285. { value: "1", label: "平台订单号" },
  286. { value: "2", label: "平台商品编号" },
  287. { value: "3", label: "PO编号" },
  288. { value: "4", label: "录入订单编号" },
  289. { value: "5", label: "导入人部门" },
  290. ],
  291. parmValue: {
  292. status: "",
  293. platform_code: "",
  294. platform_id: "",
  295. // cs3: "",
  296. po_code: "",
  297. plat_code: "",
  298. // cs6: "",
  299. platform_time_end: "",
  300. platform_time_start: "",
  301. addtime_end: "",
  302. addtime_start: "",
  303. orderCode: "",
  304. page: 1,
  305. size: 15,
  306. company_name: "", //导入人部门
  307. },
  308. changeList: [],
  309. // 表格 - 分页
  310. pageInfo: {
  311. size: 15,
  312. curr: 1,
  313. total: 0,
  314. },
  315. table: {
  316. stripe: true,
  317. border: true,
  318. _defaultHeader_: ["setcol"],
  319. },
  320. tableData: [],
  321. columns: listCol,
  322. //多前置输入框值
  323. inputValue: "",
  324. //多筛选
  325. selectValue: "1",
  326. };
  327. },
  328. computed: {
  329. //组件SIZE设置
  330. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  331. powers() {
  332. let tran =
  333. this.$store.getters.btnList.find(
  334. (item) => item.menu_route == "orderEnter"
  335. ) || {};
  336. if (tran && tran.action && tran.action.length > 0) {
  337. return tran.action;
  338. } else {
  339. return [];
  340. }
  341. },
  342. statusActive() {
  343. return function (status) {
  344. let active = "";
  345. switch (status) {
  346. case "1":
  347. active = "系统验证数据中";
  348. break;
  349. case "2":
  350. active = "待确认订单信息";
  351. break;
  352. case "3":
  353. active = "待处理(待扣减库存)";
  354. break;
  355. case "4":
  356. active = "库存不足";
  357. break;
  358. case "5":
  359. active = "订单录入成功";
  360. break;
  361. }
  362. return active;
  363. };
  364. },
  365. statusActiveTag() {
  366. return function (status) {
  367. let active = "";
  368. switch (status) {
  369. case "1":
  370. active = "";
  371. break;
  372. case "2":
  373. active = "info";
  374. break;
  375. case "3":
  376. active = "warning";
  377. break;
  378. case "4":
  379. active = "danger";
  380. break;
  381. case "5":
  382. active = "success";
  383. break;
  384. }
  385. return active;
  386. };
  387. },
  388. },
  389. mounted() {
  390. const { back } = this.$route.query;
  391. if (back) {
  392. this.parmValue = JSON.parse(back);
  393. console.log(this.parmValue);
  394. const { page, size } = this.parmValue;
  395. // this.parmValue.start = start || last_start;
  396. // this.parmValue.end = end || last_end;
  397. // if(this.parmValue.brandid.length>0){
  398. // this.brandid = [this.parmValue.brandid] ;
  399. // }
  400. this.pageInfo = {
  401. size: size,
  402. curr: page,
  403. total: 0,
  404. };
  405. //多选条件
  406. this.select = this.parmValue.select;
  407. // this.sselect = this.parmValue.sselect;
  408. this.inputValue = this.parmValue.inputValue;
  409. } else {
  410. this.select = "1";
  411. // this.sselect = "创建时间"
  412. this.tableData = [];
  413. }
  414. this.select = "1";
  415. this.searchList();
  416. },
  417. methods: {
  418. async platform_codesearchChange(e) {
  419. const { id } = e;
  420. this.parmValue.platform_id = id || "";
  421. this.pageInfo.curr = 1;
  422. this.parmValue.page = 1;
  423. await this.searchList();
  424. },
  425. getRouter(toRouter, queryId, status) {
  426. if (status === "1") {
  427. this.$message.warning(`脚本验证中的数据能查看详情!`);
  428. return;
  429. }
  430. if (toRouter && queryId) {
  431. let model = {
  432. id: queryId,
  433. type: "view",
  434. };
  435. //有多选框的条件
  436. this.parmValue.select = this.select;
  437. // this.parmValue.sselect = this.sselect ;
  438. this.parmValue.inputValue = this.inputValue;
  439. //
  440. console.log(this.parmValue);
  441. let routerModel = {
  442. options: JSON.parse(JSON.stringify(this.parmValue)),
  443. router: this.$route.path,
  444. };
  445. model.preModel = JSON.stringify(routerModel);
  446. this.routeGoto(toRouter, model);
  447. } else {
  448. this.$message.warning("暂未找到相关流程!");
  449. }
  450. },
  451. //初始化请求
  452. async searchList() {
  453. if (
  454. (this.parmValue.platform_time_start !== "" &&
  455. this.parmValue.platform_time_end === "") ||
  456. (this.parmValue.platform_time_start === "" &&
  457. this.parmValue.platform_time_end !== "")
  458. ) {
  459. this.$message.warning("平台下单时间区间不完整!");
  460. return;
  461. }
  462. if (
  463. (this.parmValue.addtime_start !== "" &&
  464. this.parmValue.addtime_end === "") ||
  465. (this.parmValue.addtime_start === "" &&
  466. this.parmValue.addtime_end !== "")
  467. ) {
  468. this.$message.warning("导入时间区间不完整!");
  469. return;
  470. }
  471. this.parmValue.platform_code =
  472. this.selectValue == "1" ? this.inputValue : "";
  473. this.parmValue.plat_code = this.selectValue == "2" ? this.inputValue : "";
  474. this.parmValue.po_code = this.selectValue == "3" ? this.inputValue : "";
  475. this.parmValue.orderCode = this.selectValue == "4" ? this.inputValue : "";
  476. this.parmValue.company_name = this.selectValue == "5" ? this.inputValue : "";
  477. this.loading = true;
  478. let res = await asyncRequest.orderimportlist(this.parmValue);
  479. if (res && res.code === 0 && res.data) {
  480. this.tableData = res.data.list;
  481. console.log(this.tableData);
  482. this.pageInfo.total = Number(res.data.count);
  483. } else if (res && res.code >= 100 && res.code <= 104) {
  484. await this.logout();
  485. } else {
  486. this.$message.warning(res.message);
  487. this.pageInfo.total = 0;
  488. }
  489. this.loading = false;
  490. },
  491. //点击批量删除按钮
  492. batchDel() {
  493. if (this.changeList.length === 0) {
  494. this.$message.warning(`请勾选有效数据后在进行删除`);
  495. return;
  496. }
  497. let isok = true,
  498. ids = [];
  499. this.changeList.forEach((item) => {
  500. console.log(item);
  501. if (item.status === "2" || item.status === "4") {
  502. ids.push(item.id);
  503. } else {
  504. isok = false;
  505. }
  506. });
  507. if (!isok) {
  508. this.$message.warning(`只能删除待确认和库存不足的订单!`);
  509. return;
  510. }
  511. this.deleteItem(ids);
  512. },
  513. //删除
  514. async deleteItem(ids) {
  515. await this.$confirm("确定要删除?", {
  516. confirmButtonText: "确定",
  517. cancelButtonText: "取消",
  518. type: "warning",
  519. })
  520. .then(async () => {
  521. const model = {
  522. ids,
  523. };
  524. const res = await asyncRequest.delimportorder(model);
  525. if (res && res.code === 0) {
  526. this.$notify.success({
  527. title: "删除成功",
  528. message: "",
  529. });
  530. this.searchList();
  531. } else if (res && res.code >= 100 && res.code <= 104) {
  532. await this.logout();
  533. } else {
  534. this.$message.warning(res.message);
  535. }
  536. })
  537. .catch(() => {
  538. console.log("取消");
  539. });
  540. },
  541. //导入时间
  542. async addtime(e) {
  543. this.parmValue.addtime_start = e.startTime || "";
  544. this.parmValue.addtime_end = e.endTime || "";
  545. await this.searchList();
  546. },
  547. //平台时间
  548. async platformTime(e) {
  549. this.parmValue.platform_time_start = e.startTime || "";
  550. this.parmValue.platform_time_end = e.endTime || "";
  551. await this.searchList();
  552. },
  553. //批量关联库存规则判断
  554. selectStockIf() {
  555. if (this.changeList.length <= 0) {
  556. this.$message.warning(`请勾选需要关联的商品`);
  557. return;
  558. }
  559. let flag = false;
  560. try {
  561. this.changeList.forEach((item, index) => {
  562. if (item.status == "4") {
  563. if (item.plat_code == this.changeList[0].plat_code) {
  564. } else {
  565. this.$message.warning(`选中的商品平台商品编号不一致`);
  566. flag = false;
  567. throw new Error("End Loop");
  568. }
  569. } else {
  570. this.$message.warning(`选中第${index + 1}行状态不是库存不足品`);
  571. flag = false;
  572. throw new Error("End Loop");
  573. }
  574. flag = true;
  575. });
  576. } catch {}
  577. console.log("判断函数", flag);
  578. return flag;
  579. },
  580. //批量关联库存
  581. async selectStock() {
  582. if (!this.selectStockIf()) {
  583. return;
  584. }
  585. let ids = [];
  586. let plat_code = this.changeList[0].plat_code;
  587. this.changeList.forEach((item) => {
  588. ids.push(item.id);
  589. });
  590. let model = {
  591. ids,
  592. plat_code,
  593. };
  594. let res = await asyncRequest.relationstockbatch(model);
  595. if (res && res.code === 0) {
  596. console.log(res);
  597. this.$message.success(res.message);
  598. this.searchList();
  599. //成功展示弹窗
  600. // this.centerDialogVisible = true;
  601. } else if (res && res.code >= 100 && res.code <= 104) {
  602. await this.logout();
  603. } else {
  604. this.$message.warning(res.message);
  605. }
  606. },
  607. //重置按钮
  608. reset() {
  609. this.select = "1";
  610. this.inputValue = "";
  611. this.parmValue = {
  612. status: "",
  613. platform_code: "",
  614. // cs3: "",
  615. po_code: "",
  616. plat_code: "",
  617. // cs6: "",
  618. platform_time_end: "",
  619. platform_time_start: "",
  620. addtime_end: "",
  621. addtime_start: "",
  622. company_name: "", //导入人部门
  623. orderCode: "",
  624. page: 1,
  625. size: 15,
  626. };
  627. this.pageInfo = {
  628. size: 15,
  629. curr: 1,
  630. total: 0,
  631. };
  632. this.selectValue = "1";
  633. this.searchList();
  634. },
  635. //刷新按钮
  636. resetF5() {
  637. this.searchList();
  638. },
  639. //订单导入入口
  640. entry() {
  641. this.$router.push("/orderEntry/orderImport");
  642. },
  643. //选中触发函数
  644. selection_change(e) {
  645. console.log(e);
  646. const { list } = e;
  647. //选中的数组集合
  648. this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
  649. },
  650. },
  651. };
  652. </script>
  653. <style lang="scss" scoped>
  654. </style>