index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <div class="purchaseOrder 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. @selection="selection_change"
  24. >
  25. <template #table-header="{}">
  26. <div style="width: 100%">
  27. <el-row style="padding: 0 0 0 80px">
  28. <el-col :span="4" style="width: 150px">
  29. <el-select
  30. :size="searchSize"
  31. v-model="parmValue.status"
  32. filterable
  33. clearable
  34. placeholder="采购单状态"
  35. style="width: 100%"
  36. @change="
  37. pageInfo.curr = 1;
  38. parmValue.page = 1;
  39. searchList();
  40. "
  41. >
  42. <el-option
  43. v-for="item in statusOptions"
  44. :key="'status' + item.value"
  45. :label="item.label"
  46. :value="item.value"
  47. />
  48. </el-select>
  49. </el-col>
  50. <!-- <el-col :span="4" style="width: 310px; padding: 0 0 0 10px">
  51. <search-supplier
  52. :size="searchSize"
  53. :value="wsm_supplierNo"
  54. :placeholder="'入库公司名称'"
  55. :disabled="false"
  56. :names="supplierName"
  57. :isDetail="true"
  58. @searchChange="supplierChange"
  59. />
  60. </el-col>
  61. <el-col :span="4" style="width: 220px; padding: 0 0 0 10px">
  62. <search-stock
  63. :size="searchSize"
  64. :value="wsm_code"
  65. :placeholder="'入库仓库名称'"
  66. :disabled="false"
  67. :names="stockName"
  68. :isDetail="true"
  69. :isRelation="true"
  70. :companyCode="parmValue.wsm_supplierNo"
  71. @searchChange="stockChange"
  72. />
  73. </el-col> -->
  74. <el-col :span="4" style="width: 130px; padding: 0 0 0 10px">
  75. <el-dropdown @command="handleClick($event)" :size="searchSize">
  76. <el-button :size="searchSize" style="width: 120px">
  77. {{ sselect }}
  78. <i class="el-icon-arrow-down el-icon--right" :size="searchSize"></i>
  79. </el-button>
  80. <el-dropdown-menu slot="dropdown">
  81. <el-dropdown-item
  82. v-for="item in options"
  83. :key="item"
  84. :command="item"
  85. >{{ item }}</el-dropdown-item
  86. >
  87. </el-dropdown-menu>
  88. </el-dropdown>
  89. </el-col>
  90. <el-col :span="4" style="width: 303px; padding: 0 0 0 10px">
  91. <period-date-picker
  92. :type="1"
  93. :width="'135px'"
  94. :size="searchSize"
  95. :start="timeOBJ.start"
  96. :end="timeOBJ.end"
  97. @timeReturned="handleTime"
  98. />
  99. </el-col>
  100. <el-col :span="3" style="width: 66px; float: right">
  101. <el-button
  102. :size="searchSize"
  103. type="primary"
  104. style="float: right; margin-left: 5px"
  105. @click="searchList"
  106. >
  107. 刷新
  108. </el-button>
  109. </el-col>
  110. <el-col
  111. :span="4"
  112. style="width: 150px; float: right"
  113. v-if="powers.some((i) => i == '089')"
  114. >
  115. <el-button
  116. type="primary"
  117. @click="statusConfirm"
  118. :size="searchSize"
  119. class="fr"
  120. >
  121. 批量已与供应商确认
  122. </el-button>
  123. </el-col>
  124. </el-row>
  125. <el-row style="padding: 10px 0 0 0">
  126. <el-col :span="6" style="width: 500px; padding: 0 0 0 0px">
  127. <el-input
  128. clearable
  129. placeholder="关键字"
  130. v-model="input"
  131. maxlength="40"
  132. :size="searchSize"
  133. class="input-with-select"
  134. @blur="
  135. pageInfo.curr = 1;
  136. parmValue.page = 1;
  137. searchList();
  138. "
  139. >
  140. <el-select
  141. v-model="select"
  142. style="width: 125px"
  143. slot="prepend"
  144. placeholder="关键字类型"
  145. @change="
  146. pageInfo.curr = 1;
  147. parmValue.page = 1;
  148. searchList();
  149. "
  150. >
  151. <el-option label="采购单编号" value="1"></el-option>
  152. <!-- <el-option label="入库单编号" value="2"></el-option> -->
  153. <!-- 列表未渲染备库编号,注释 -->
  154. <!-- <el-option label="备库编号" value="3"></el-option> -->
  155. <el-option label="商品成本编号" value="4"></el-option>
  156. <el-option label="商品名称" value="5"></el-option>
  157. <el-option label="供应商负责人" value="6"></el-option>
  158. <el-option label="采购供应商编号" value="7"></el-option>
  159. <el-option label="订单编号" value="8"></el-option>
  160. <el-option label="供应商负责人部门" value="9"></el-option>
  161. </el-select>
  162. </el-input>
  163. </el-col>
  164. <el-col :span="4" style="width: 66px; float: right">
  165. <el-button
  166. type="warning"
  167. class="fr"
  168. :size="searchSize"
  169. @click="restSearch"
  170. >
  171. 重置
  172. </el-button>
  173. </el-col>
  174. <!-- 暂时注释,下版需要导出 -->
  175. <el-col
  176. :span="4"
  177. style="width: 66px; float: right"
  178. v-if="powers.some((i) => i == '087')"
  179. >
  180. <el-button
  181. type="primary"
  182. style="margin-left: 30px"
  183. @click="download"
  184. :size="searchSize"
  185. class="fr"
  186. >
  187. 导出
  188. </el-button>
  189. </el-col>
  190. </el-row>
  191. </div>
  192. </template>
  193. <template #good_name="{ scope }">
  194. <span>{{ scope.row.good_name }}</span>
  195. <span v-for="(si, i) in scope.row.speclist" :key="si.spec_id + i">
  196. {{ i === 0 ? "__" : "--" }}{{ si.spec_name }}[{{ si.spec_value }}]
  197. </span>
  198. </template>
  199. <template #status="{ scope }">
  200. <el-tag
  201. :size="tablebtnSize"
  202. v-text="
  203. (statusOptions.find((item) => item.value == scope.row.status) || {})
  204. .label || '--'
  205. "
  206. ></el-tag>
  207. </template>
  208. <template #order_id="{ scope }">
  209. <el-tag
  210. :size="tablebtnSize"
  211. v-text="
  212. (
  213. cg_order_type_options.find((item) => item.id == scope.row.order_type) ||
  214. {}
  215. ).label || '--'
  216. "
  217. ></el-tag>
  218. </template>
  219. <template #operation="{ scope }">
  220. <el-tooltip
  221. v-if="powers.some((i) => i == '007')"
  222. effect="dark"
  223. content="详情"
  224. placement="top"
  225. >
  226. <i
  227. class="el-icon-view tb-icon"
  228. @click="getRouter('purchaseOrderDetail', scope.row.cgdNo)"
  229. ></i>
  230. </el-tooltip>
  231. </template>
  232. </ex-table>
  233. </div>
  234. <div v-else>
  235. <no-auth></no-auth>
  236. </div>
  237. </div>
  238. </template>
  239. <script>
  240. import mixinPage from "@/mixins/elPaginationHandle";
  241. import resToken from "@/mixins/resToken";
  242. import urlConfig from "@/apis/url-config";
  243. import asyncRequest from "@/apis/service/purchaseIn/purchaseOrder";
  244. import { columns, statusOptions } from "./columns";
  245. import { cg_order_type_options } from "@/assets/js/statusList";
  246. import { mapGetters } from "vuex";
  247. export default {
  248. name: "purchaseOrder",
  249. mixins: [mixinPage, resToken],
  250. components: {},
  251. computed: {
  252. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  253. powers() {
  254. const tran =
  255. this.$store.getters.btnList.find((item) => item.menu_route == "purchaseOrder") ||
  256. {};
  257. const { action } = tran ?? {};
  258. return action ?? [];
  259. },
  260. },
  261. data() {
  262. return {
  263. //入库公司
  264. supplierName: "",
  265. cg_order_type_options,
  266. //入库仓库
  267. stockName: "",
  268. changeList: [],
  269. fileUrl: urlConfig.baseURL,
  270. sitem: null,
  271. select: "1",
  272. input: "",
  273. timeOBJ: {
  274. start: "", //起始时间
  275. end: "", // 结束时间
  276. },
  277. options: ["创建时间", "最晚入库时间"],
  278. sselect: "创建时间",
  279. // 状态
  280. statusOptions: statusOptions,
  281. loading: false,
  282. showModel: false,
  283. isDetail: false,
  284. modelId: 0,
  285. wsm_code: [],
  286. wsm_supplierNo: [],
  287. parmValue: {
  288. orderCode: "", // 订单编号
  289. bk_code: "", // 备库编码
  290. wsm_in_code: "", // 入库单号
  291. cgdNo: "", // 采购单编码
  292. apply_name: "", // 申请人
  293. good_name: "", // 产品名称
  294. good_code: "", // 产品属性编号
  295. status: "", //状态
  296. wsm_code: "", //入货仓库编码
  297. start: "", //新建起始时间
  298. end: "", // 新建结束时间
  299. last_start: "", //最后入库时间开始
  300. last_end: "", //最后入库时间结束
  301. page: 1, // 页码
  302. size: 15, // 每页显示条数
  303. supplierNo: "",
  304. company_name: "", //部门
  305. wsm_supplierNo: "",
  306. },
  307. tableData: [],
  308. passwordModel: false,
  309. passwordModelId: 0,
  310. isPasswordDetail: false,
  311. // 表格 - 数据
  312. tableData: [],
  313. // 表格 - 参数
  314. table: {
  315. stripe: true,
  316. border: true,
  317. _defaultHeader_: ["setcol"],
  318. },
  319. // 表格 - 分页
  320. pageInfo: {
  321. size: 15,
  322. curr: 1,
  323. total: 0,
  324. },
  325. // 表格 - 列参数
  326. columns: columns,
  327. };
  328. },
  329. mounted() {
  330. const { back } = this.$route.query;
  331. if (back) {
  332. this.parmValue = JSON.parse(back);
  333. console.log(this.parmValue);
  334. const { page, size, start, end, last_start, last_end } = this.parmValue;
  335. this.timeOBJ.start = start || last_start;
  336. this.timeOBJ.end = end || last_end;
  337. this.pageInfo = {
  338. size: size,
  339. curr: page,
  340. total: 0,
  341. };
  342. //多选条件
  343. this.select = this.parmValue.select;
  344. this.sselect = this.parmValue.sselect;
  345. this.input = this.parmValue.input;
  346. //入库公司
  347. // this.supplierName = localStorage.getItem("wsm_supplierNo")
  348. // if(this.supplierName.length>0){
  349. // this.wsm_supplierNo = [this.parmValue.wsm_supplierNo];
  350. // this.stockName = localStorage.getItem("wsm_code")
  351. // this.wsm_code = [this.parmValue.wsm_code]
  352. // }
  353. // console.log(this.supplierName)
  354. } else {
  355. this.select = "1";
  356. this.sselect = "创建时间";
  357. }
  358. this.searchList();
  359. },
  360. methods: {
  361. getRouter(toRouter, queryId) {
  362. if (toRouter && queryId) {
  363. let model = {
  364. id: queryId,
  365. };
  366. //有多选框的条件
  367. this.parmValue.select = this.select;
  368. this.parmValue.sselect = this.sselect;
  369. this.parmValue.input = this.input;
  370. //
  371. let routerModel = {
  372. options: JSON.parse(JSON.stringify(this.parmValue)),
  373. router: this.$route.path,
  374. };
  375. model.preModel = JSON.stringify(routerModel);
  376. this.routeGoto(toRouter, model);
  377. } else {
  378. this.$message.warning("暂未找到相关流程!");
  379. }
  380. },
  381. //选中触发函数
  382. selection_change(e) {
  383. const { list } = e;
  384. //选中的数组集合
  385. this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
  386. },
  387. //导出文件
  388. async download() {
  389. if (this.changeList.length <= 0) {
  390. this.$message.warning("请选择有效数据");
  391. return;
  392. }
  393. let model = {
  394. cgdNos: [],
  395. };
  396. this.changeList.forEach((item) => {
  397. model.cgdNos.push(item.cgdNo);
  398. });
  399. // const res = await asyncRequest.exportcgdlist(model)
  400. if (!this.loading) {
  401. this.loading = true;
  402. let httpType = `aplication/zip`;
  403. axios({
  404. method: "post",
  405. url: this.fileUrl + "admin/exportcgdlist",
  406. responseType: "blob",
  407. data: model,
  408. headers: {
  409. // 'Content-Type': 'multipart/form-data',
  410. // Accept: "application/vnd.ms-excel"
  411. Accept: httpType,
  412. },
  413. })
  414. .then((res) => {
  415. // console.log(res)
  416. // console.log(this.fileUrl)
  417. // return;
  418. if (res && res.status == 200 && res.data) {
  419. let url = window.URL.createObjectURL(
  420. new Blob([res.data], {
  421. // type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
  422. type: httpType,
  423. })
  424. );
  425. let link = document.createElement("a");
  426. link.style.display = "none";
  427. link.href = url;
  428. let excelName = "采购单.zip";
  429. link.setAttribute("download", excelName);
  430. document.body.appendChild(link);
  431. link.click();
  432. link.remove();
  433. window.URL.revokeObjectURL(url); //释放掉blob对象
  434. this.$message.success(`${message}导出成功!`);
  435. setTimeout(() => {
  436. this.loading = false;
  437. }, 500);
  438. } else {
  439. this.$message.error(res.data.message);
  440. setTimeout(() => {
  441. this.loading = false;
  442. }, 500);
  443. }
  444. })
  445. .catch((error) => {
  446. console.log(error);
  447. this.loading = false;
  448. });
  449. }
  450. },
  451. async statusConfirm() {
  452. if (this.changeList.length <= 0) {
  453. this.$message.warning("至少选择一条采购单数据!");
  454. return;
  455. }
  456. let isok = true,
  457. iss = false,
  458. list = [],
  459. errorList = [];
  460. this.changeList.forEach((e) => {
  461. if (e.status !== "0") {
  462. isok = false;
  463. }
  464. if (
  465. e.has_account + "" !== "0" &&
  466. (e.order_type + "" === "2" || e.order_type + "" === "3")
  467. ) {
  468. iss = true;
  469. errorList.push(e.cgdNo);
  470. }
  471. list.push(e.cgdNo);
  472. });
  473. if (!isok) {
  474. this.$message.warning("只能选择待与供应商确认的采购单!");
  475. return;
  476. }
  477. if (iss) {
  478. let htmlList = "<ul>";
  479. errorList.forEach((v) => {
  480. console.log(v);
  481. htmlList += `<li>${v}</li>`;
  482. });
  483. htmlList += "</ul>";
  484. this.$notify({
  485. title: "以下采购单对应的供应商账号已开启,不允许在本系统操作!",
  486. dangerouslyUseHTMLString: true,
  487. message: htmlList,
  488. });
  489. return;
  490. }
  491. await this.$confirm(`确定批量确认?`, {
  492. confirmButtonText: "确定",
  493. cancelButtonText: "取消",
  494. type: "warning",
  495. })
  496. .then(async () => {
  497. let model = {
  498. cgdNo: list,
  499. status: "1",
  500. };
  501. const { code, data, message } = await asyncRequest.status(model);
  502. this.loading = false;
  503. if (code === 0) {
  504. this.$notify.success({
  505. title: "提交成功!",
  506. message: "",
  507. });
  508. await this.searchList();
  509. } else if (code === 1003) {
  510. this.showal(data, message, "");
  511. } else if (code >= 100 && code <= 104) {
  512. await this.logout();
  513. } else {
  514. this.$message.warning(message);
  515. }
  516. })
  517. .catch(() => {
  518. console.log("取消");
  519. });
  520. },
  521. showal(list, message, code) {
  522. let htmlList = "<ul>";
  523. list.forEach((v) => {
  524. htmlList += `<li>${code !== "" ? v[code] : v}</li>`;
  525. });
  526. htmlList += "</ul>";
  527. this.$notify({
  528. title: message,
  529. dangerouslyUseHTMLString: true,
  530. message: htmlList,
  531. });
  532. },
  533. restSearch() {
  534. this.sselect = "创建时间";
  535. this.select = "1";
  536. this.input = "";
  537. this.wsm_code = [];
  538. this.wsm_supplierNo = [];
  539. this.timeOBJ = {
  540. start: "", //起始时间
  541. end: "", // 结束时间
  542. };
  543. this.parmValue = {
  544. bk_code: "", // 备库编码
  545. wsm_in_code: "", // 入库单号
  546. cgdNo: "", // 采购单编码
  547. apply_name: "", // 申请人
  548. good_name: "", // 产品名称
  549. good_code: "", // 产品属性编号
  550. status: "", //状态
  551. wsm_code: "", //入货仓库编码
  552. start: "", //新建起始时间
  553. end: "", // 新建结束时间
  554. last_start: "", //最后入库时间开始
  555. last_end: "", //最后入库时间结束
  556. orderCode: "", //订单编号
  557. company_name: "", //部门
  558. page: 1, // 页码
  559. size: 15, // 每页显示条数
  560. };
  561. // 表格 - 分页
  562. this.pageInfo = {
  563. size: 15,
  564. curr: 1,
  565. total: 0,
  566. };
  567. this.searchList();
  568. },
  569. async handleClick(e) {
  570. this.sselect = e;
  571. this.parmValue.start = e === "创建时间" ? this.timeOBJ.start : "";
  572. this.parmValue.end = e === "创建时间" ? this.timeOBJ.end : "";
  573. this.parmValue.last_start = e !== "创建时间" ? this.timeOBJ.start : "";
  574. this.parmValue.last_end = e !== "创建时间" ? this.timeOBJ.end : "";
  575. if (
  576. !(
  577. (this.timeOBJ.start !== "" && this.timeOBJ.end === "") ||
  578. (this.timeOBJ.start === "" && this.timeOBJ.end !== "")
  579. )
  580. ) {
  581. this.parmValue.page = 1;
  582. this.pageInfo.curr = 1;
  583. await this.searchList();
  584. }
  585. },
  586. async supplierChange(e) {
  587. if (e && e.id) {
  588. //入库公司
  589. // localStorage.setItem("wsm_supplierNo",e.label)
  590. // this.supplierName = localStorage.getItem("rkNm")
  591. this.parmValue.wsm_supplierNo = e.code;
  592. this.wsm_supplierNo = [e.code];
  593. } else {
  594. //入库公司
  595. // localStorage.setItem("wsm_supplierNo","")
  596. this.parmValue.wsm_supplierNo = "";
  597. this.wsm_supplierNo = [];
  598. }
  599. this.parmValue.wsm_code = "";
  600. this.wsm_code = [];
  601. this.parmValue.page = 1;
  602. this.pageInfo.curr = 1;
  603. await this.searchList();
  604. },
  605. async stockChange(e) {
  606. if (e && e.id) {
  607. //入库仓库
  608. // localStorage.setItem("wsm_code",e.label)
  609. this.parmValue.wsm_code = e.code;
  610. this.wsm_code = [e.code];
  611. } else {
  612. //入库仓库
  613. // localStorage.setItem("wsm_code","")
  614. this.parmValue.wsm_code = "";
  615. this.wsm_code = [];
  616. }
  617. this.parmValue.page = 1;
  618. this.pageInfo.curr = 1;
  619. await this.searchList();
  620. },
  621. async searchList() {
  622. if (
  623. (this.timeOBJ.start !== "" && this.timeOBJ.end === "") ||
  624. (this.timeOBJ.start === "" && this.timeOBJ.end !== "")
  625. ) {
  626. this.$message.warning("时间区间不完整!");
  627. return;
  628. }
  629. this.loading = true;
  630. this.parmValue.cgdNo = this.select === "1" ? this.input : ""; // 采购单编码
  631. this.parmValue.wsm_in_code = this.select === "2" ? this.input : ""; // 入库单号
  632. this.parmValue.bk_code = this.select === "3" ? this.input : ""; // 备库编码
  633. this.parmValue.good_code = this.select === "4" ? this.input : ""; // 产品属性编号
  634. this.parmValue.good_name = this.select === "5" ? this.input : ""; // 产品名称
  635. this.parmValue.apply_name = this.select === "6" ? this.input : ""; // 申请人
  636. this.parmValue.supplierNo = this.select === "7" ? this.input : ""; // 采购供应商编号
  637. this.parmValue.orderCode = this.select === "8" ? this.input : ""; // 采购供应商编号
  638. this.parmValue.company_name = this.select === "9" ? this.input : ""; // 部门
  639. console.log(this.pageInfo);
  640. // this.wsm_supplierNo = [];
  641. const res = await asyncRequest.list(this.parmValue);
  642. if (res && res.code === 0 && res.data) {
  643. this.tableData = res.data.list;
  644. this.pageInfo.total = Number(res.data.count);
  645. } else if (res && res.code >= 100 && res.code <= 104) {
  646. await this.logout();
  647. } else {
  648. this.tableData = [];
  649. this.pageInfo.total = 0;
  650. }
  651. this.loading = false;
  652. },
  653. // 时间
  654. async handleTime(e) {
  655. if (e.startTime !== "") {
  656. this.timeOBJ.start = e.startTime;
  657. } else {
  658. this.timeOBJ.start = "";
  659. }
  660. if (e.endTime !== "") {
  661. this.timeOBJ.end = e.endTime;
  662. } else {
  663. this.timeOBJ.end = "";
  664. }
  665. await this.handleClick(this.sselect);
  666. },
  667. },
  668. };
  669. </script>
  670. <style lang="scss" scoped>
  671. .purchaseOrder {
  672. // text-align: right;
  673. }
  674. </style>