index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <div class="salesOrder pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  5. >
  6. <ex-table
  7. v-loading="loading"
  8. :table="table"
  9. :data="tableData"
  10. :columns="columns"
  11. :page="pageInfo"
  12. :size="size"
  13. @page-curr-change="handlePageChange"
  14. @page-size-change="handleSizeChange"
  15. @screen-reset="
  16. pageInfo.curr = 1;
  17. parmValue.page = 1;
  18. searchList();
  19. "
  20. @screen-submit="
  21. pageInfo.curr = 1;
  22. parmValue.page = 1;
  23. searchList();
  24. "
  25. >
  26. <template #table-header="{ selection }">
  27. <div style="width: 100%">
  28. <el-row style="padding: 0 0 0 80px">
  29. <el-col :span="6" style="width: 293px; padding: 0 0 0 0px">
  30. <period-date-picker
  31. :type="1"
  32. :width="'135px'"
  33. :size="searchSize"
  34. :start="parmValue.start"
  35. :end="parmValue.end"
  36. @timeReturned="handleTime"
  37. />
  38. </el-col>
  39. <el-col :span="4" style="width: 148px; padding: 0 0 0 8px">
  40. <el-select
  41. :size="searchSize"
  42. v-model="parmValue.status"
  43. filterable
  44. clearable
  45. placeholder="订单状态"
  46. style="width: 100%"
  47. @change="
  48. pageInfo.curr = 1;
  49. parmValue.page = 1;
  50. searchList();
  51. "
  52. >
  53. <el-option
  54. v-for="item in statusOptions"
  55. :key="'status' + item.id"
  56. :label="item.label"
  57. :value="item.id"
  58. />
  59. </el-select>
  60. </el-col>
  61. <!-- 客户公司 -->
  62. <el-col :span="4" style="width: 240px; padding: 0 0 0 10px">
  63. <search-work-company
  64. :type="'1'"
  65. :value="parmValue.supplierNo"
  66. :size="'mini'"
  67. :placeholder="'销售方公司'"
  68. :disabled="false"
  69. :isDetail="false"
  70. @searchChange="supplierChange"
  71. />
  72. </el-col>
  73. <el-col :span="3" style="width: 66px; float: right">
  74. <el-button
  75. :size="searchSize"
  76. type="primary"
  77. style="float: right; margin-left: 5px"
  78. @click="searchList"
  79. >
  80. 刷新
  81. </el-button>
  82. </el-col>
  83. <el-col :span="3" style="width: 66px; float: right">
  84. <el-button
  85. :size="searchSize"
  86. type="primary"
  87. style="float: right; margin-left: 5px"
  88. @click="set_user(selection)"
  89. >
  90. 设置订单用途
  91. </el-button>
  92. </el-col>
  93. </el-row>
  94. <el-row style="padding: 10px 0 0 0">
  95. <el-col :span="6" style="width: 371px">
  96. <search-customer
  97. :value="customerCode"
  98. :size="searchSize"
  99. :placeholder="'客户公司名称'"
  100. @searchChange="customerChange"
  101. />
  102. </el-col>
  103. <el-col :span="4" style="width: 150px; padding: 0 0 0 9px">
  104. <el-select
  105. :size="searchSize"
  106. v-model="parmValue.order_type"
  107. filterable
  108. clearable
  109. placeholder="订单类型"
  110. style="width: 100%"
  111. @change="
  112. pageInfo.curr = 1;
  113. parmValue.page = 1;
  114. searchList();
  115. "
  116. >
  117. <el-option
  118. v-for="item in orderOptions"
  119. :key="'orderstatus' + item.id"
  120. :label="item.label"
  121. :value="item.id"
  122. />
  123. </el-select>
  124. </el-col>
  125. <el-col :span="6" style="width: 325px; padding: 0 0 0 10px">
  126. <el-input
  127. clearable
  128. placeholder="关键字"
  129. v-model="input"
  130. :size="searchSize"
  131. @blur="searchList"
  132. class="input-with-select"
  133. >
  134. <el-select
  135. v-model="select"
  136. style="width: 100px"
  137. slot="prepend"
  138. placeholder="请选择"
  139. @change="searchList"
  140. >
  141. <el-option label="订单编号" value="orderCode"></el-option>
  142. <!-- <el-option
  143. label="商品属性编号"
  144. value="good_code"
  145. ></el-option> -->
  146. <!-- <el-option
  147. label="供应商编号"
  148. value="supplierNo"
  149. ></el-option> -->
  150. <!-- <el-option
  151. label="客户编号"
  152. value="customer_code"
  153. ></el-option> -->
  154. <el-option label="商品名称" value="good_name"></el-option>
  155. <el-option label="申请人" value="apply_name"></el-option>
  156. </el-select>
  157. </el-input>
  158. </el-col>
  159. <el-col :span="4" style="width: 66px; float: right">
  160. <el-button
  161. type="warning"
  162. class="fr"
  163. :size="searchSize"
  164. @click="restSearch"
  165. >
  166. 重置
  167. </el-button>
  168. </el-col>
  169. <el-col
  170. :span="3"
  171. style="width: 56px; float: right"
  172. v-if="powers.some((item) => item == '003')"
  173. >
  174. <el-button
  175. :size="searchSize"
  176. type="success"
  177. style="float: right"
  178. @click="
  179. routeGoto('salesOrderDetail', { id: 'add', type: 'add' })
  180. "
  181. >
  182. 新建
  183. </el-button>
  184. </el-col>
  185. </el-row>
  186. </div>
  187. </template>
  188. <template #good_name="{ scope }">
  189. <span>{{ scope.row.good_name }}</span>
  190. <span v-for="(si, i) in scope.row.speclist" :key="si.spec_id + i">
  191. <span v-if="i !== 0">-</span>
  192. <span v-else>_</span>
  193. <span>{{ si.spec_name }}[{{ si.spec_value }}]</span>
  194. </span>
  195. </template>
  196. <template #status="{ scope }">
  197. <el-tag
  198. :size="tablebtnSize"
  199. :type="scope.row.status == '0' ? 'warning' : ''"
  200. v-text="
  201. (statusOptions.find((item) => item.id == scope.row.status) || {})
  202. .label || '--'
  203. "
  204. ></el-tag>
  205. </template>
  206. <template #order_type="{ scope }">
  207. <el-tag
  208. :size="tablebtnSize"
  209. v-text="
  210. (
  211. orderOptions.find((item) => item.id == scope.row.order_type) ||
  212. {}
  213. ).label || '--'
  214. "
  215. ></el-tag>
  216. </template>
  217. <template #operation="{ scope }">
  218. <el-tooltip effect="dark" content="详情" placement="top">
  219. <i
  220. class="el-icon-view tb-icon"
  221. @click="
  222. routeGoto('salesOrderDetail', {
  223. id: scope.row.id,
  224. type: 'view',
  225. })
  226. "
  227. ></i>
  228. </el-tooltip>
  229. </template>
  230. </ex-table>
  231. <add-edit
  232. :id="modelId"
  233. :sitem="sitem"
  234. :show-model="showModel"
  235. :is-detail="isDetail"
  236. @refresh="searchList"
  237. @cancel="showModel = false"
  238. />
  239. <!--订单用途设置-->
  240. <user-add-edit
  241. :code="orderCodeList"
  242. :show-model="userShowModel"
  243. @refresh="searchList"
  244. @cancel="userShowModel = false"
  245. />
  246. </div>
  247. <div v-else>
  248. <no-auth></no-auth>
  249. </div>
  250. </div>
  251. </template>
  252. <script>
  253. import mixinPage from "@/mixins/elPaginationHandle";
  254. import resToken from "@/mixins/resToken";
  255. import asyncRequest from "@/apis/service/sellOut/salesOrder";
  256. import columns from "./columns"; //表格列参数
  257. import addEdit from "./components/addEdit";
  258. import userAddEdit from "./userAddEdit";
  259. import { mapGetters } from "vuex";
  260. export default {
  261. name: "salesOrder",
  262. mixins: [mixinPage, resToken],
  263. components: {
  264. addEdit,
  265. userAddEdit,
  266. },
  267. computed: {
  268. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  269. powers() {
  270. let tran =
  271. this.$store.getters.btnList.find(
  272. (item) => item.menu_route == "salesOrder"
  273. ) || {};
  274. if (tran && tran.action && tran.action.length > 0) {
  275. return tran.action;
  276. } else {
  277. return [];
  278. }
  279. },
  280. },
  281. data() {
  282. return {
  283. sitem: null,
  284. select: "orderCode",
  285. input: "",
  286. customerCode: [],
  287. // 状态
  288. statusOptions: [
  289. { id: "0", label: "待发货" },
  290. { id: "1", label: "待发货完成" },
  291. { id: "2", label: "发货已完成" },
  292. { id: "3", label: "订单已取消" },
  293. ],
  294. orderOptions: [
  295. { id: "1", label: "线上商品销售" },
  296. { id: "2", label: "项目线上商品销售" },
  297. { id: "3", label: "咨询单销售" },
  298. { id: "4", label: "项目咨询单销售" },
  299. ],
  300. loading: false,
  301. showModel: false,
  302. isDetail: false,
  303. modelId: 0,
  304. parmValue: {
  305. order_type: "", //订单类型
  306. orderCode: "", //销售订单code
  307. apply_name: "", // 申请人
  308. good_name: "", // 产品名称
  309. good_code: "", // 产品属性编号
  310. status: "", //状态
  311. page: 1, // 页码
  312. size: 15, // 每页显示条数
  313. supplierNo: "", //供应商编号
  314. customer_code: "", //客户编号
  315. start: "", //新建起始时间
  316. end: "", // 新建结束时间
  317. },
  318. // 表格 - 数据
  319. tableData: [],
  320. // 表格 - 参数
  321. table: {
  322. stripe: true,
  323. border: true,
  324. _defaultHeader_: ["setcol"],
  325. },
  326. // 表格 - 分页
  327. pageInfo: {
  328. size: 15,
  329. curr: 1,
  330. total: 0,
  331. },
  332. // 表格 - 列参数
  333. columns: columns,
  334. orderCodeList: [],
  335. userShowModel: false,
  336. };
  337. },
  338. mounted() {
  339. this.searchList();
  340. },
  341. methods: {
  342. restSearch() {
  343. this.select = "orderCode";
  344. this.input = "";
  345. this.customerCode = [];
  346. this.parmValue = {
  347. order_type: "", //订单类型1为销售 2为咨询
  348. orderCode: "", //销售订单code
  349. apply_name: "", // 申请人
  350. good_name: "", // 产品名称
  351. good_code: "", // 产品属性编号
  352. status: "", //状态
  353. page: 1, // 页码
  354. size: 15, // 每页显示条数
  355. supplierNo: "", //供应商编号
  356. customer_code: "", //客户编号
  357. start: "", //新建起始时间
  358. end: "", // 新建结束时间
  359. };
  360. // 表格 - 分页
  361. this.pageInfo = {
  362. size: 15,
  363. curr: 1,
  364. total: 0,
  365. };
  366. this.searchList();
  367. },
  368. openModal(id, isDetail, sitem) {
  369. this.modelId = id;
  370. this.isDetail = isDetail;
  371. this.sitem = sitem;
  372. this.showModel = true;
  373. },
  374. async supplierChange(e) {
  375. const { id, code, label } = e;
  376. this.parmValue.supplierNo = code || "";
  377. this.parmValue.page = 1;
  378. this.pageInfo.curr = 1;
  379. await this.searchList();
  380. },
  381. set_user(selection) {
  382. if (selection.length === 0) {
  383. this.$message.warning("至少选择一个订单!");
  384. return;
  385. }
  386. this.orderCodeList = [];
  387. let isok = true;
  388. selection.forEach((e) => {
  389. this.orderCodeList.push(e.orderCode);
  390. if (e.use_order) {
  391. isok = false;
  392. }
  393. });
  394. if (!isok) {
  395. this.$message.warning("只能选择未绑定的订单!");
  396. return;
  397. }
  398. this.userShowModel = true;
  399. },
  400. // 客户选择
  401. async customerChange(e) {
  402. if (e && e.id) {
  403. this.customerCode = [e.code];
  404. this.parmValue.customer_code = e.code;
  405. } else {
  406. this.customerCode = [];
  407. this.parmValue.customer_code = "";
  408. }
  409. this.parmValue.page = 1;
  410. this.pageInfo.curr = 1;
  411. await this.searchList();
  412. },
  413. async stockChange(e) {
  414. if (e && e.id) {
  415. this.parmValue.stockNo = [e.code];
  416. } else {
  417. this.parmValue.stockNo = [];
  418. }
  419. this.parmValue.page = 1;
  420. this.pageInfo.curr = 1;
  421. await this.searchList();
  422. },
  423. async searchList() {
  424. this.loading = true;
  425. this.parmValue.orderCode = this.select === "orderCode" ? this.input : "";
  426. this.parmValue.good_name = this.select === "good_name" ? this.input : "";
  427. this.parmValue.apply_name =
  428. this.select === "apply_name" ? this.input : "";
  429. const res = await asyncRequest.list(this.parmValue);
  430. if (res && res.code === 0 && res.data) {
  431. this.tableData = res.data.list;
  432. this.tableData.forEach((v) => {
  433. v.good_class = "";
  434. if (v.can && v.can.length > 0) {
  435. v.can.forEach((x, i) => {
  436. v.good_class += i === 0 ? x.name : "_" + x.name;
  437. });
  438. }
  439. });
  440. this.pageInfo.total = Number(res.data.count);
  441. } else if (res && res.code >= 100 && res.code <= 104) {
  442. await this.logout();
  443. } else {
  444. this.tableData = [];
  445. this.pageInfo.total = 0;
  446. }
  447. this.loading = false;
  448. },
  449. // 时间
  450. async handleTime(e) {
  451. if (e.startTime !== "") {
  452. this.parmValue.start = e.startTime;
  453. } else {
  454. this.parmValue.start = "";
  455. }
  456. if (e.endTime !== "") {
  457. this.parmValue.end = e.endTime;
  458. } else {
  459. this.parmValue.end = "";
  460. }
  461. },
  462. },
  463. };
  464. </script>
  465. <style lang="scss" scoped>
  466. .salesOrder {
  467. // text-align: right;
  468. }
  469. </style>