index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. :cell-style="cellStyle"
  20. @selection-change="selectionChange"
  21. @search-criteria-switch="searchCriteriaSwitch"
  22. >
  23. <template slot="createTimeSearch">
  24. <el-date-picker
  25. v-model="search.createTime"
  26. type="daterange"
  27. start-placeholder="开始日期"
  28. end-placeholder="结束日期"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd HH:mm:ss"
  31. :default-time="['00:00:00', '23:59:59']"
  32. >
  33. </el-date-picker>
  34. </template>
  35. <template slot="menuLeft">
  36. <el-button
  37. type="primary"
  38. icon="el-icon-plus"
  39. size="small"
  40. @click.stop="newAdd('new')"
  41. >创建单据
  42. </el-button>
  43. <el-button
  44. type="success"
  45. size="small"
  46. @click.stop="copyDoc()"
  47. :disabled="selectionList.length != 1"
  48. >复制单据
  49. </el-button>
  50. <el-button type="info" size="small" disabled>报表打印</el-button>
  51. <el-button type="info" size="small" @click="dialogVisible = true;">导入销售单</el-button>
  52. </template>
  53. <template slot="corpIdSearch">
  54. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  55. </template>
  56. <template slot="businesDateSearch">
  57. <el-date-picker
  58. v-model="search.businesDate"
  59. type="daterange"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期"
  62. format="yyyy-MM-dd"
  63. value-format="yyyy-MM-dd HH:mm:ss"
  64. :default-time="['00:00:00', '23:59:59']">
  65. </el-date-picker>
  66. </template>
  67. <template slot="plannedDeliveryDateSearch">
  68. <el-date-picker
  69. v-model="search.plannedDeliveryDate"
  70. type="daterange"
  71. start-placeholder="开始日期"
  72. end-placeholder="结束日期"
  73. format="yyyy-MM-dd"
  74. value-format="yyyy-MM-dd HH:mm:ss"
  75. :default-time="['00:00:00', '23:59:59']"
  76. >
  77. </el-date-picker>
  78. </template>
  79. <template slot="requiredDeliveryDateSearch">
  80. <el-date-picker
  81. v-model="search.requiredDeliveryDate"
  82. type="daterange"
  83. start-placeholder="开始日期"
  84. end-placeholder="结束日期"
  85. format="yyyy-MM-dd"
  86. value-format="yyyy-MM-dd HH:mm:ss"
  87. :default-time="['00:00:00', '23:59:59']"
  88. >
  89. </el-date-picker>
  90. </template>
  91. <template slot-scope="scope" slot="corpId">
  92. <span
  93. style="color: #409EFF;cursor: pointer"
  94. @click.stop="editOpen(scope.row, 1)"
  95. >{{ scope.row.strCorpName }}
  96. </span>
  97. </template>
  98. <template slot-scope="scope" slot="orderNo">
  99. <span
  100. style="color: #409EFF;cursor: pointer"
  101. @click.stop="editOpen(scope.row, 1)"
  102. >{{ scope.row.orderNo }}
  103. </span>
  104. </template>
  105. <template slot-scope="scope" slot="fudaPurchaseStatus">
  106. <span class="el-button--text">
  107. {{scope.row.fudaPurchaseStatus}}
  108. </span>
  109. </template>
  110. <template slot-scope="scope" slot="fudaPurchaseDate">
  111. <span class="el-button--text">
  112. {{scope.row.fudaPurchaseDate}}
  113. </span>
  114. </template>
  115. <template slot-scope="scope" slot="productionScheduling">
  116. <span class="el-button--text">
  117. {{scope.row.productionScheduling}}
  118. </span>
  119. </template>
  120. <template slot-scope="scope" slot="createUser">
  121. {{ scope.row.createUserName }}
  122. </template>
  123. <template slot-scope="{ row }" slot="orderQuantity">
  124. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  125. </template>
  126. <template slot-scope="scope" slot="menu">
  127. <el-button
  128. type="text"
  129. icon="el-icon-delete"
  130. size="small"
  131. @click.stop="rowDel(scope.row, scope.index)"
  132. >删除
  133. </el-button>
  134. </template>
  135. </avue-crud>
  136. </basic-container>
  137. <detail-page
  138. @goBack="goBack"
  139. @copyOrder="copyOrder"
  140. :detailData="detailData"
  141. v-if="!show"
  142. ></detail-page>
  143. <el-dialog
  144. title="导入销售单"
  145. v-if="dialogVisible"
  146. :visible.sync="dialogVisible"
  147. append-to-body
  148. :close-on-click-modal="false"
  149. :close-on-press-escape="false"
  150. :before-close="function() {
  151. dialogVisible = false;params={}
  152. }"
  153. top="1vh"
  154. width="90%">
  155. <span>
  156. <el-row>
  157. <el-col :span="6" style="padding: 0 10px">
  158. <el-scrollbar>
  159. <avue-tree :option="treeOption" :key="avueTree" :data="treeData" @node-click="nodeClick"/>
  160. </el-scrollbar>
  161. </el-col>
  162. <el-col :span="18">
  163. <!-- :page.sync="dialogPage"-->
  164. <avue-crud
  165. :data="dialogData"
  166. :option="dialogOption"
  167. :search.sync="params"
  168. ref="dialogCrud"
  169. @resetColumn="resetColumnTwo('dialogCrud','dialogOption','dialogOptionList',2.1)"
  170. @saveColumn="saveColumnTwo('dialogCrud','dialogOption','dialogOptionList',2.1)"
  171. @refresh-change="refreshChangeTwo"
  172. @search-change="searchChangeTwo"
  173. @search-reset="searchReset"
  174. @on-load="dialogOnLoad">
  175. <template slot="menuLeft">
  176. <el-tabs v-model="activeName" @tab-click="tabHandle">
  177. <el-tab-pane label="查询结果" name="searchList"/>
  178. <el-tab-pane label="已选定数据" name="importStaging"/>
  179. </el-tabs>
  180. </template>
  181. <template slot="corpNameSearch">
  182. <crop-select v-model="params.corpId" corpType="GYS"/>
  183. </template>
  184. <template slot-scope="scope" slot="menu">
  185. <el-button
  186. type="text"
  187. icon="el-icon-edit"
  188. size="small"
  189. @click.stop="importStagList(scope.row, scope.index)"
  190. v-if="activeName == 'searchList'"
  191. :disabled=" goodsListSave.findIndex(item => item.id == scope.row.id) !== -1 "
  192. >选择
  193. </el-button>
  194. <el-button
  195. type="text"
  196. icon="el-icon-delete"
  197. size="small"
  198. @click.stop="removeStagList(scope.row, scope.index)"
  199. v-else
  200. >移除
  201. </el-button>
  202. </template>
  203. </avue-crud>
  204. </el-col>
  205. </el-row>
  206. </span>
  207. <span slot="footer" class="dialog-footer">
  208. <el-button @click="dialogVisible = false;params={}">取 消</el-button>
  209. <el-button type="primary" :disabled="goodsListSave.length === 0" @click="confirmImport">导 入</el-button>
  210. </span>
  211. </el-dialog>
  212. </div>
  213. </template>
  214. <script>
  215. import option from "./config/mainList.json";
  216. import {getList, remove, gainUser, listXS,generatePurchaseBill,listBYStatus} from "@/api/exportTrade/purchaseContract";
  217. import detailPage from "./detailsPage.vue";
  218. import { defaultDate } from "@/util/date";
  219. import { IntegerFormat } from "@/util/validate";
  220. import {customerParameter} from "@/enums/management-type";
  221. export default {
  222. name: "customerInformation",
  223. data() {
  224. return {
  225. search: {
  226. businesDate: defaultDate()
  227. },
  228. treeData: [],
  229. avueTree: false,
  230. treeOption: {
  231. nodeKey: "id",
  232. lazy: true,
  233. treeLoad: function (node, resolve) {
  234. listBYStatus({}).then(res => {
  235. resolve(
  236. res.data.data.map(item => {
  237. return {
  238. ...item,
  239. leaf: !item.hasChildren
  240. };
  241. })
  242. );
  243. });
  244. },
  245. addBtn: false,
  246. menu: false,
  247. size: "small",
  248. props: {
  249. labelText: "标题",
  250. label: "orderNo",
  251. value: "id",
  252. children: "children"
  253. }
  254. },
  255. dialogData: [],
  256. goodsListShow: [],
  257. goodsListSave: [],
  258. params:{},
  259. dialogPage: {
  260. pageSize: 20,
  261. currentPage: 1,
  262. total: 0,
  263. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  264. },
  265. activeName: 'searchList',
  266. dialogOption: {},
  267. dialogOptionList: {
  268. searchShow: true,
  269. searchMenuSpan: 16,
  270. border: true,
  271. index: true,
  272. viewBtn: false,
  273. editBtn: false,
  274. delBtn: false,
  275. addBtn: false,
  276. menuWidth: "100",
  277. headerAlign: "center",
  278. searchIcon: true,
  279. searchIndex: 2,
  280. tip: false,
  281. column: [
  282. {
  283. label: "销售单号",
  284. prop: "billNo",
  285. search: true,
  286. searchSpan: 8,
  287. overHidden: true
  288. }, {
  289. label: "销售日期",
  290. prop: "businesDate",
  291. searchProp: "businesDateList",
  292. width: 100,
  293. type: "date",
  294. searchSpan: 8,
  295. searchRange: true,
  296. search: true,
  297. searchDefaultTime: ["00:00:00", "23:59:59"],
  298. format: "yyyy-MM-dd",
  299. valueFormat: "yyyy-MM-dd HH:mm:ss",
  300. overHidden: true
  301. }, {
  302. label: "供应商",
  303. prop: "corpName",
  304. searchSpan: 8,
  305. search: true,
  306. overHidden: true
  307. }, {
  308. label: "交货日期",
  309. prop: "plannedDeliveryDate",
  310. searchProp: "plannedDeliveryDateList",
  311. width: 100,
  312. type: "date",
  313. searchSpan: 8,
  314. searchRange: true,
  315. search: true,
  316. searchDefaultTime: ["00:00:00", "23:59:59"],
  317. format: "yyyy-MM-dd",
  318. valueFormat: "yyyy-MM-dd HH:mm:ss",
  319. overHidden: true
  320. }, {
  321. label: "采购员",
  322. prop: "carry",
  323. overHidden: true
  324. }, {
  325. label: "产品名称",
  326. prop: "cname",
  327. overHidden: true
  328. }, {
  329. label: "产品编号",
  330. prop: "code",
  331. overHidden: true
  332. }, {
  333. label: "产品类别",
  334. prop: "priceCategory",
  335. overHidden: true
  336. }, {
  337. label: "产品型号",
  338. prop: "itemType",
  339. overHidden: true
  340. }, {
  341. label: "数量",
  342. prop: "orderQuantity",
  343. overHidden: true
  344. }, {
  345. label: "采购数",
  346. prop: "purchaseQuantity",
  347. overHidden: true
  348. }]
  349. },
  350. dialogVisible: false,
  351. form: {},
  352. option: {},
  353. parentId: 0,
  354. dataList: [],
  355. page: {
  356. pageSize: 20,
  357. currentPage: 1,
  358. total: 0,
  359. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  360. },
  361. totalTwo:0,
  362. show: true,
  363. detailData: {},
  364. loading: false,
  365. selectionList: []
  366. };
  367. },
  368. components: { detailPage },
  369. async created() {
  370. this.option = await this.getColumnData(this.getColumnName(2), option);
  371. this.dialogOption = await this.getColumnData(this.getColumnName(2.1), this.dialogOptionList);
  372. this.getWorkDicts("payment_term").then(res => {
  373. this.findObject(this.option.column, "paymentType").dicData = res.data.data;
  374. });
  375. gainUser().then(res => {
  376. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  377. });
  378. this.option.height = window.innerHeight - 210;
  379. },
  380. filters: {
  381. IntegerFormat(num) {
  382. return IntegerFormat(num);
  383. }
  384. },
  385. activated(){
  386. if (this.$route.query.check){
  387. this.detailData = {
  388. id: this.$route.query.check.billId
  389. };
  390. this.show = false;
  391. this.$store.commit("IN_CG_STATUS");
  392. }
  393. },
  394. methods: {
  395. nodeClick(data) {
  396. this.params.pid = data.id
  397. this.dialogPage.currentPage = 1;
  398. this.dialogOnLoad(this.dialogPage);
  399. },
  400. removeStagList(row, index) {
  401. this.goodsListSave.splice(row.$index, 1);
  402. },
  403. searchCriteriaSwitch(type) {
  404. if (type) {
  405. this.option.height = this.option.height - 139;
  406. } else {
  407. this.option.height = this.option.height + 139;
  408. }
  409. this.$refs.crud.getTableHeight();
  410. },
  411. cellStyle() {
  412. return "padding:0;height:40px;";
  413. },
  414. //删除列表后面的删除按钮触发触发(row, index, done)
  415. rowDel(row, index, done) {
  416. this.$confirm("确定删除数据?", {
  417. confirmButtonText: "确定",
  418. cancelButtonText: "取消",
  419. type: "warning"
  420. }).then(() => {
  421. remove(row.id).then(res => {
  422. if (res.data.code == 200) {
  423. this.$message({
  424. type: "success",
  425. message: "删除成功!"
  426. });
  427. this.onLoad(this.page, this.search);
  428. }
  429. });
  430. });
  431. },
  432. selectionChange(list) {
  433. this.selectionList = list;
  434. },
  435. copyDoc() {
  436. this.selectionList.forEach(e => {
  437. this.detailData = {
  438. id: e.id,
  439. status: "copy"
  440. };
  441. this.show = false;
  442. });
  443. },
  444. copyOrder(id) {
  445. this.show = true;
  446. this.detailData = {
  447. id: id,
  448. status: "copy"
  449. };
  450. this.$nextTick(() => {
  451. this.show = false;
  452. });
  453. },
  454. editOpen(row, status) {
  455. this.detailData = {
  456. id: row.id,
  457. status: status
  458. };
  459. this.show = false;
  460. },
  461. //点击搜索按钮触发
  462. searchChange(params, done) {
  463. if (params.businesDate) {
  464. params.businesStartDate = params.businesDate[0];
  465. params.businesEndDate = params.businesDate[1];
  466. }
  467. if (params.requiredDeliveryDate) {
  468. params.requiredDeliveryStartDate = params.requiredDeliveryDate[0];
  469. params.requiredDeliveryEndDate = params.requiredDeliveryDate[1];
  470. }
  471. delete params.businesDate;
  472. delete params.requiredDeliveryDate;
  473. this.page.currentPage = 1;
  474. this.onLoad(this.page, params);
  475. done();
  476. },
  477. currentChange(val) {
  478. this.page.currentPage = val;
  479. },
  480. sizeChange(val) {
  481. this.page.currentPage = 1;
  482. this.page.pageSize = val;
  483. },
  484. // 标签页切换
  485. tabHandle(data) {
  486. if (data.name == 'searchList') {
  487. this.dialogData = this.goodsListShow;
  488. this.dialogPage.total = this.totalTwo
  489. } else if (data.name == 'importStaging') {
  490. this.goodsListShow = this.dialogData;
  491. this.dialogData = this.goodsListSave;
  492. this.totalTwo = this.dialogPage.total
  493. this.dialogPage.total = 0
  494. }
  495. },
  496. importStagList(row, index) {
  497. this.goodsListSave.push(row);
  498. },
  499. refreshChangeTwo(){
  500. this.dialogOnLoad(this.page);
  501. },
  502. searchChangeTwo(params, done) {
  503. done()
  504. if (!this.params.pid && !this.params.billNo) {
  505. return this.$message.error("请选择左边单号或输入销售单号")
  506. } else {
  507. this.dialogOnLoad(this.page);
  508. }
  509. },
  510. searchReset() {
  511. this.avueTree = !this.avueTree
  512. this.dialogData = []
  513. },
  514. //自定义列保存
  515. async saveColumnTwo(ref, option, optionBack, code) {
  516. /**
  517. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  518. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  519. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  520. */
  521. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  522. if (inSave) {
  523. this.$message.success("保存成功");
  524. //关闭窗口
  525. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  526. }
  527. },
  528. //自定义列重置
  529. async resetColumnTwo(ref, option, optionBack, code) {
  530. this[option] = this[optionBack];
  531. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  532. if (inSave) {
  533. this.$message.success("重置成功");
  534. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  535. }
  536. },
  537. confirmImport(){
  538. let ids = this.goodsListSave.map(item => {return item.id})
  539. const loading = this.$loading({
  540. lock: true,
  541. text: '加载中',
  542. spinner: 'el-icon-loading',
  543. background: 'rgba(255,255,255,0.7)'
  544. });
  545. generatePurchaseBill({ids:ids.join(',')}).then(res=>{
  546. this.$message.success("导入成功")
  547. this.detailData = {
  548. form: res.data.data
  549. };
  550. loading.close()
  551. this.dialogVisible = false
  552. setTimeout(() => {
  553. this.show = false;
  554. }, 200);
  555. }).catch(()=>{
  556. loading.close()
  557. })
  558. },
  559. dialogOnLoad(page, params) {
  560. this.dialogLoading = true;
  561. params = {
  562. ...params,
  563. size: page.pageSize,
  564. current: page.currentPage,
  565. ...this.params
  566. }
  567. if (this.params.pid || this.params.billNo) {
  568. listXS(params).then(res => {
  569. this.dialogLoading = false
  570. this.dialogData = res.data.data
  571. // this.dialogPage.total = res.data.data.total
  572. })
  573. }
  574. },
  575. onLoad(page, params) {
  576. if (this.search.businesDate && this.search.businesDate.length > 0) {
  577. params = {
  578. ...params,
  579. orderStartDate: this.search.businesDate[0],
  580. orderEndDate: this.search.businesDate[1]
  581. };
  582. delete params.businesDate;
  583. }
  584. if (this.search.requiredDeliveryDate && this.search.requiredDeliveryDate.length > 0) {
  585. params = {
  586. ...params,
  587. requiredDeliveryStartDate: this.search.requiredDeliveryDate[0],
  588. requiredDeliveryEndDate: this.search.requiredDeliveryDate[1]
  589. };
  590. delete params.requiredDeliveryDate
  591. }
  592. this.loading = true;
  593. getList(page.currentPage, page.pageSize, params)
  594. .then(res => {
  595. this.dataList = res.data.data.records ? res.data.data.records : [];
  596. this.page.total = res.data.data.total;
  597. })
  598. .finally(() => {
  599. this.loading = false;
  600. });
  601. },
  602. refreshChange() {
  603. this.onLoad(this.page, this.search);
  604. },
  605. newAdd(type) {
  606. this.detailData = {
  607. pageType: type
  608. };
  609. this.show = false;
  610. },
  611. goBack() {
  612. this.detailData = this.$options.data().detailData;
  613. this.show = true;
  614. this.onLoad(this.page, this.search);
  615. },
  616. async saveColumn() {
  617. const inSave = await this.saveColumnData(
  618. this.getColumnName(2),
  619. this.option
  620. );
  621. if (inSave) {
  622. this.$nextTick(() => {
  623. this.$refs.crud.doLayout();
  624. });
  625. this.$message.success("保存成功");
  626. //关闭窗口
  627. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  628. }
  629. },
  630. async resetColumn() {
  631. this.option = option;
  632. const inSave = await this.delColumnData(this.getColumnName(2), option);
  633. if (inSave) {
  634. this.$nextTick(() => {
  635. this.$refs.crud.doLayout();
  636. });
  637. this.$message.success("重置成功");
  638. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  639. }
  640. }
  641. },
  642. watch: {
  643. option: function() {
  644. this.search.businesDate = defaultDate();
  645. },
  646. dialogVisible:function (){
  647. this.goodsListShow = []
  648. this.goodsListSave = []
  649. this.totalTwo = 0
  650. }
  651. }
  652. };
  653. </script>
  654. <style scoped>
  655. ::v-deep .select-component {
  656. display: flex;
  657. }
  658. .page-crad ::v-deep .basic-container__card {
  659. height: 94.2vh;
  660. }
  661. </style>