index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <template>
  2. <div class="salesOrder pagePadding">
  3. <div v-if="powers.some((i) => i == '001')">
  4. <ex-table
  5. v-loading="loading"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{ selection }">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 0 80px">
  27. <el-col :span="6" style="width: 293px; padding: 0 0 0 0px">
  28. <period-date-picker
  29. :type="1"
  30. :width="'135px'"
  31. :size="searchSize"
  32. :start="parmValue.start"
  33. :end="parmValue.end"
  34. @timeReturned="handleTime"
  35. />
  36. </el-col>
  37. <el-col :span="4" style="width: 148px; padding: 0 0 0 8px">
  38. <el-select
  39. :size="searchSize"
  40. v-model="parmValue.status"
  41. filterable
  42. clearable
  43. placeholder="订单状态"
  44. style="width: 100%"
  45. @change="
  46. pageInfo.curr = 1;
  47. parmValue.page = 1;
  48. searchList();
  49. "
  50. >
  51. <el-option
  52. v-for="item in statusOptions"
  53. :key="'status' + item.id"
  54. :label="item.label"
  55. :value="item.id"
  56. />
  57. </el-select>
  58. </el-col>
  59. <el-col :span="4" style="width: 150px; padding: 0 0 0 9px">
  60. <el-select
  61. :size="searchSize"
  62. v-model="parmValue.use_type"
  63. filterable
  64. placeholder="平台类型"
  65. style="width: 100%"
  66. @change="
  67. pageInfo.curr = 1;
  68. parmValue.page = 1;
  69. searchList();
  70. "
  71. >
  72. <el-option
  73. v-for="item in usetypeOtions"
  74. :key="'use_type' + item.id"
  75. :label="item.label"
  76. :value="item.value"
  77. />
  78. </el-select>
  79. </el-col>
  80. <el-col :span="3" style="width: 66px; float: right">
  81. <el-button
  82. :size="searchSize"
  83. type="primary"
  84. style="float: right; margin-left: 5px"
  85. @click="searchList"
  86. >
  87. 刷新
  88. </el-button>
  89. </el-col>
  90. <el-col :span="3" style="width: 66px; float: right" v-if="!isSupertube && powers.includes('094')">
  91. <el-button
  92. :size="searchSize"
  93. type="primary"
  94. style="float: right; margin-left: 5px"
  95. @click="set_user(selection)"
  96. >
  97. 设置订单用途
  98. </el-button>
  99. </el-col>
  100. </el-row>
  101. <el-row style="padding: 10px 0 0 0">
  102. <el-col :span="6" style="width: 371px">
  103. <search-customer
  104. :value="customerCode"
  105. :size="searchSize"
  106. :names="parmValue.supplierName"
  107. :is-detail="true"
  108. :placeholder="'企业客户'"
  109. @searchChange="customerChange"
  110. />
  111. </el-col>
  112. <el-col :span="4" style="width: 150px; padding: 0 0 0 9px">
  113. <el-select
  114. :size="searchSize"
  115. v-model="parmValue.order_source"
  116. filterable
  117. clearable
  118. placeholder="订单来源"
  119. style="width: 100%"
  120. @change="
  121. pageInfo.curr = 1;
  122. parmValue.page = 1;
  123. searchList();
  124. "
  125. >
  126. <el-option
  127. v-for="item in xs_order_source_options"
  128. :key="'orderstatus' + item.id"
  129. :label="item.label"
  130. :value="item.id"
  131. />
  132. </el-select>
  133. </el-col>
  134. <el-col :span="4" style="width: 150px; padding: 0 0 0 9px">
  135. <el-select
  136. :size="searchSize"
  137. v-model="parmValue.order_type"
  138. filterable
  139. clearable
  140. placeholder="商品类型"
  141. style="width: 100%"
  142. @change="
  143. pageInfo.curr = 1;
  144. parmValue.page = 1;
  145. searchList();
  146. "
  147. >
  148. <el-option
  149. v-for="item in xs_order_type_options"
  150. :key="'orderstatus' + item.id"
  151. :label="item.label"
  152. :value="item.id"
  153. />
  154. </el-select>
  155. </el-col>
  156. <el-col :span="4" style="width: 66px; float: right">
  157. <el-button
  158. type="warning"
  159. class="fr"
  160. :size="searchSize"
  161. @click="restSearch"
  162. >
  163. 重置
  164. </el-button>
  165. </el-col>
  166. <el-col
  167. :span="3"
  168. style="width: 56px; float: right"
  169. v-if="powers.some((i) => i == '003') && !isSupertube"
  170. >
  171. <el-button
  172. :size="searchSize"
  173. type="success"
  174. style="float: right"
  175. @click="routeGoto('salesOrderDetail', { id: 'add', type: 'add' })"
  176. >
  177. 新建
  178. </el-button>
  179. </el-col>
  180. </el-row>
  181. <el-row style="padding: 10px 0 0 0">
  182. <el-col :span="6" style="width: 426px">
  183. <el-input
  184. clearable
  185. placeholder="关键字"
  186. v-model="input"
  187. maxlength="40"
  188. :size="searchSize"
  189. @blur="searchList"
  190. class="input-with-select"
  191. >
  192. <el-select
  193. v-model="select"
  194. style="width: 100px"
  195. slot="prepend"
  196. placeholder="关键字类型"
  197. @change="searchList"
  198. >
  199. <el-option label="订单编号" value="orderCode"></el-option>
  200. <el-option label="商品名称" value="good_name"></el-option>
  201. <el-option label="创建人" value="apply_name"></el-option>
  202. <el-option label="创建人部门" value="company_name"></el-option>
  203. </el-select>
  204. <el-button
  205. slot="append"
  206. icon="el-icon-search"
  207. @click="
  208. pageInfo.curr = 1;
  209. parmValue.page = 1;
  210. searchList();
  211. "
  212. ></el-button>
  213. </el-input>
  214. </el-col>
  215. </el-row>
  216. </div>
  217. </template>
  218. <template #good_name="{ scope }">
  219. <span>{{ scope.row.good_name }}</span>
  220. <span v-for="(si, i) in scope.row.speclist" :key="si.spec_id + i">
  221. <span v-if="i !== 0">-</span>
  222. <span v-else>_</span>
  223. <span>{{ si.spec_name }}[{{ si.spec_value }}]</span>
  224. </span>
  225. </template>
  226. <template #use_type="{ scope }">
  227. <el-tag size="mini">
  228. {{
  229. (usetypeOtions.find(({ value }) => value === scope.row.use_type) || {})
  230. .label || "---"
  231. }}
  232. </el-tag>
  233. </template>
  234. <template #cgd_status="{ scope }">
  235. <el-tag size="mini">
  236. <template v-if="String(scope.row.order_type) === '1'">--</template>
  237. <template v-else>{{
  238. (
  239. purchaseStatusOptions.find(
  240. ({ value }) => value === scope.row.cgd_status
  241. ) || {}
  242. ).label || "---"
  243. }}</template>
  244. </el-tag>
  245. </template>
  246. <template #status="{ scope }">
  247. <el-tag
  248. :size="tablebtnSize"
  249. :type="scope.row.status == '0' ? 'warning' : ''"
  250. v-text="
  251. (statusOptions.find((item) => item.id == scope.row.status) || {}).label ||
  252. '--'
  253. "
  254. ></el-tag>
  255. </template>
  256. <template #order_type="{ scope }">
  257. <el-tag
  258. :size="tablebtnSize"
  259. v-text="
  260. (
  261. xs_order_type_options.find((item) => item.id == scope.row.order_type) ||
  262. {}
  263. ).label || '--'
  264. "
  265. ></el-tag>
  266. </template>
  267. <template #order_source="{ scope }">
  268. <el-tag
  269. :size="tablebtnSize"
  270. v-text="
  271. (
  272. xs_order_source_options.find(
  273. (item) => item.id == scope.row.order_source
  274. ) || {}
  275. ).label || '--'
  276. "
  277. ></el-tag>
  278. </template>
  279. <template #operation="{ scope }">
  280. <el-tooltip effect="dark" content="详情" placement="top">
  281. <i
  282. class="el-icon-view tb-icon"
  283. @click="getRouter('salesOrderDetail', scope.row.id)"
  284. ></i>
  285. </el-tooltip>
  286. <el-tooltip
  287. content="撤销"
  288. placement="top"
  289. v-if="isCancel(scope.row) && powers.includes('006') && !isSupertube"
  290. >
  291. <i
  292. class="el-icon-refresh-right tb-icon"
  293. @click="handleOrderCancel(scope.row)"
  294. />
  295. </el-tooltip>
  296. </template>
  297. </ex-table>
  298. <add-edit
  299. :id="modelId"
  300. :sitem="sitem"
  301. :show-model="showModel"
  302. :is-detail="isDetail"
  303. @refresh="searchList"
  304. @cancel="showModel = false"
  305. />
  306. <!--订单用途设置-->
  307. <user-add-edit
  308. :code="orderCodeList"
  309. :show-model="userShowModel"
  310. @refresh="searchList"
  311. @cancel="userShowModel = false"
  312. />
  313. </div>
  314. <div v-else>
  315. <no-auth></no-auth>
  316. </div>
  317. </div>
  318. </template>
  319. <script>
  320. import mixinPage from "@/mixins/elPaginationHandle";
  321. import resToken from "@/mixins/resToken";
  322. import asyncRequest from "@/apis/service/sellOut/salesOrder";
  323. import columns from "./columns"; //表格列参数
  324. import addEdit from "./components/addEdit";
  325. import userAddEdit from "./userAddEdit";
  326. import { mapGetters } from "vuex";
  327. import companyHelper from "@/mixins/companyHelper";
  328. // import {} from "@/utils/stat"
  329. import {
  330. xs_order_type_options,
  331. xs_order_source_options,
  332. usetypeOtions,
  333. } from "@/assets/js/statusList";
  334. import { MessageBox } from "element-ui";
  335. export default {
  336. name: "salesOrder",
  337. mixins: [mixinPage, resToken, companyHelper],
  338. components: {
  339. addEdit,
  340. userAddEdit,
  341. },
  342. computed: {
  343. ...mapGetters(["tablebtnSize", "searchSize", "size", "isSupertube"]),
  344. powers() {
  345. const tran =
  346. this.$store.getters.btnList.find((item) => item.menu_route == "salesOrder") || {};
  347. const { action } = tran ?? {};
  348. return action ?? [];
  349. },
  350. },
  351. data() {
  352. return {
  353. sitem: null,
  354. select: "orderCode",
  355. input: "",
  356. usetypeOtions,
  357. customerCode: [],
  358. // 状态
  359. statusOptions: [
  360. { id: "0", label: "待发货" },
  361. { id: "1", label: "待发货完成" },
  362. { id: "2", label: "发货已完成" },
  363. { id: "3", label: "订单已取消" },
  364. ],
  365. /* 采购单状态 **/
  366. purchaseStatusOptions: [
  367. { value: "0", label: "待与供应商确认" },
  368. { value: "1", label: "待入库" },
  369. { value: "2", label: "部分入库" },
  370. { value: "3", label: "入库完成" },
  371. { value: "4", label: "已取消订单" },
  372. ],
  373. xs_order_type_options,
  374. xs_order_source_options,
  375. loading: false,
  376. showModel: false,
  377. isDetail: false,
  378. modelId: 0,
  379. parmValue: {
  380. use_type: "",
  381. order_source: "",
  382. order_type: "", //订单来源
  383. orderCode: "", //销售订单code
  384. apply_name: "", // 申请人
  385. good_name: "", // 产品名称
  386. good_code: "", // 产品属性编号
  387. status: "", //状态
  388. page: 1, // 页码
  389. size: 15, // 每页显示条数
  390. supplierNo: "", //供应商编号
  391. customer_code: "", //客户编号
  392. start: "", //新建起始时间
  393. end: "", // 新建结束时间
  394. company_name: "", //创建人部门
  395. use_type: "1",
  396. },
  397. // 表格 - 数据
  398. tableData: [],
  399. // 表格 - 参数
  400. table: {
  401. stripe: true,
  402. border: true,
  403. _defaultHeader_: ["setcol"],
  404. },
  405. // 表格 - 分页
  406. pageInfo: {
  407. size: 15,
  408. curr: 1,
  409. total: 0,
  410. },
  411. // 表格 - 列参数
  412. columns: columns,
  413. orderCodeList: [],
  414. userShowModel: false,
  415. };
  416. },
  417. mounted() {
  418. const { back } = this.$route.query;
  419. if (back) {
  420. this.parmValue = JSON.parse(back);
  421. const { page, size } = this.parmValue;
  422. // this.parmValue.start = start || last_start;
  423. // this.parmValue.end = end || last_end;
  424. if (this.parmValue.customer_code.length > 0) {
  425. this.customerCode = [this.parmValue.customer_code];
  426. }
  427. this.pageInfo = {
  428. size: size,
  429. curr: page,
  430. total: 0,
  431. };
  432. //多选条件
  433. this.select = this.parmValue.select;
  434. // this.sselect = this.parmValue.sselect;
  435. this.input = this.parmValue.input;
  436. } else {
  437. this.select = "orderCode";
  438. // this.sselect = "创建时间"
  439. }
  440. this.searchList();
  441. },
  442. methods: {
  443. isCancel(row) {
  444. const { status, order_type, cgd_status } = row;
  445. // 库存品&&未发货直接撤销 || 除了库存品以外的商品类型&&采购单未入库的可以撤销
  446. // const isStock = status === '0' && order_type === '1';
  447. // const isInStock = cgd_status && (cgd_status === '0' || cgd_status === '1')
  448. // return isStock || (!isStock && isInStock)
  449. /* CHANGE: 未发货可直接撤销 **/
  450. return status === "0";
  451. },
  452. handleOrderCancel(row) {
  453. MessageBox.confirm("是否确认撤销该销售订单?").then(async () => {
  454. const { orderCode } = row;
  455. const { code, message } = await asyncRequest.orderCancel({
  456. orderCode: [orderCode],
  457. });
  458. switch (code) {
  459. case 0:
  460. this.searchList();
  461. break;
  462. default:
  463. this.$message.warning(message);
  464. break;
  465. }
  466. });
  467. },
  468. getRouter(toRouter, queryId) {
  469. if (toRouter && queryId) {
  470. let model = {
  471. id: queryId,
  472. type: "view",
  473. };
  474. //有多选框的条件
  475. this.parmValue.select = this.select;
  476. // this.parmValue.sselect = this.sselect ;
  477. this.parmValue.input = this.input;
  478. //
  479. let routerModel = {
  480. options: JSON.parse(JSON.stringify(this.parmValue)),
  481. router: this.$route.path,
  482. };
  483. model.preModel = JSON.stringify(routerModel);
  484. this.routeGoto(toRouter, model);
  485. } else {
  486. this.$message.warning("暂未找到相关流程!");
  487. }
  488. },
  489. restSearch() {
  490. this.select = "orderCode";
  491. this.input = "";
  492. this.customerCode = [];
  493. this.parmValue = {
  494. order_type: "",
  495. orderCode: "", //销售订单code
  496. apply_name: "", // 申请人
  497. good_name: "", // 产品名称
  498. good_code: "", // 产品属性编号
  499. status: "", //状态
  500. page: 1, // 页码
  501. size: 15, // 每页显示条数
  502. supplierNo: "", //供应商编号
  503. customer_code: "", //客户编号
  504. start: "", //新建起始时间
  505. end: "", // 新建结束时间
  506. company_name: "", //部门
  507. use_type: "1",
  508. };
  509. // 表格 - 分页
  510. this.pageInfo = {
  511. size: 15,
  512. curr: 1,
  513. total: 0,
  514. };
  515. this.searchList();
  516. },
  517. openModal(id, isDetail, sitem) {
  518. this.modelId = id;
  519. this.isDetail = isDetail;
  520. this.sitem = sitem;
  521. this.showModel = true;
  522. },
  523. async supplierChange(e) {
  524. const { id, code, label } = e;
  525. this.parmValue.supplierNo = code || "";
  526. this.parmValue.page = 1;
  527. this.pageInfo.curr = 1;
  528. await this.searchList();
  529. },
  530. set_user(selection) {
  531. if (selection.length === 0) {
  532. this.$message.warning("至少选择一个订单!");
  533. return;
  534. }
  535. this.orderCodeList = [];
  536. let isok = true;
  537. selection.forEach((e) => {
  538. this.orderCodeList.push(e.orderCode);
  539. if (e.use_order) {
  540. isok = false;
  541. }
  542. });
  543. if (!isok) {
  544. this.$message.warning("只能选择未绑定的订单!");
  545. return;
  546. }
  547. this.userShowModel = true;
  548. },
  549. // 客户选择
  550. async customerChange(e) {
  551. if (e && e.id) {
  552. this.customerCode = [e.code];
  553. this.parmValue.supplierName = e.label;
  554. this.parmValue.customer_code = e.code;
  555. } else {
  556. this.customerCode = [];
  557. this.parmValue.supplierName = "";
  558. this.parmValue.customer_code = "";
  559. }
  560. this.parmValue.page = 1;
  561. this.pageInfo.curr = 1;
  562. await this.searchList();
  563. },
  564. async stockChange(e) {
  565. if (e && e.id) {
  566. this.parmValue.stockNo = [e.code];
  567. } else {
  568. this.parmValue.stockNo = [];
  569. }
  570. this.parmValue.page = 1;
  571. this.pageInfo.curr = 1;
  572. await this.searchList();
  573. },
  574. async searchList() {
  575. if (
  576. (this.parmValue.start !== "" && this.parmValue.end === "") ||
  577. (this.parmValue.start === "" && this.parmValue.end !== "")
  578. ) {
  579. this.$message.warning("时间区间不完整!");
  580. return;
  581. }
  582. this.loading = true;
  583. this.parmValue.orderCode = this.select === "orderCode" ? this.input : "";
  584. this.parmValue.good_name = this.select === "good_name" ? this.input : "";
  585. this.parmValue.apply_name = this.select === "apply_name" ? this.input : "";
  586. this.parmValue.company_name = this.select === "company_name" ? this.input : "";
  587. const res = await asyncRequest.list({
  588. ...this.parmValue,
  589. needRela: true,
  590. });
  591. if (res && res.code === 0 && res.data) {
  592. this.tableData = res.data.list;
  593. this.tableData.forEach((v) => {
  594. v.good_class = "";
  595. if (v.can && v.can.length > 0) {
  596. v.can.forEach((x, i) => {
  597. v.good_class += i === 0 ? x.name : "_" + x.name;
  598. });
  599. }
  600. });
  601. this.pageInfo.total = Number(res.data.count);
  602. } else if (res && res.code >= 100 && res.code <= 104) {
  603. await this.logout();
  604. } else {
  605. this.tableData = [];
  606. this.pageInfo.total = 0;
  607. }
  608. this.loading = false;
  609. },
  610. // 时间
  611. async handleTime(e) {
  612. if (e.startTime !== "") {
  613. this.parmValue.start = e.startTime;
  614. } else {
  615. this.parmValue.start = "";
  616. }
  617. if (e.endTime !== "") {
  618. this.parmValue.end = e.endTime;
  619. } else {
  620. this.parmValue.end = "";
  621. }
  622. },
  623. },
  624. };
  625. </script>
  626. <style lang="scss" scoped>
  627. .salesOrder {
  628. // text-align: right;
  629. }
  630. </style>