index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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="createUser">
  106. {{ scope.row.createUserName }}
  107. </template>
  108. <template slot-scope="{ row }" slot="orderQuantity">
  109. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  110. </template>
  111. <template slot-scope="scope" slot="menu">
  112. <el-button
  113. type="text"
  114. icon="el-icon-delete"
  115. size="small"
  116. @click.stop="rowDel(scope.row, scope.index)"
  117. >删除
  118. </el-button>
  119. </template>
  120. </avue-crud>
  121. </basic-container>
  122. <detail-page
  123. @goBack="goBack"
  124. @copyOrder="copyOrder"
  125. :detailData="detailData"
  126. v-if="!show"
  127. ></detail-page>
  128. <el-dialog
  129. title="导入销售单"
  130. v-if="dialogVisible"
  131. :visible.sync="dialogVisible"
  132. append-to-body
  133. width="80%">
  134. <span>
  135. <avue-crud :data="dialogData"
  136. :option="dialogOption"
  137. :page.sync="dialogPage"
  138. :search.sync="params"
  139. ref="dialogCrud"
  140. @resetColumn="resetColumnTwo('dialogCrud','dialogOption','dialogOptionList',2.1)"
  141. @saveColumn="saveColumnTwo('dialogCrud','dialogOption','dialogOptionList',2.1)"
  142. @refresh-change="refreshChangeTwo"
  143. @search-change="searchChangeTwo"
  144. @on-load="dialogOnLoad">
  145. <template slot="menuLeft">
  146. <el-tabs v-model="activeName" @tab-click="tabHandle">
  147. <el-tab-pane label="查询结果" name="searchList"/>
  148. <el-tab-pane label="已选定数据" name="importStaging"/>
  149. </el-tabs>
  150. </template>
  151. <template slot="corpNameSearch">
  152. <crop-select v-model="params.corpId" corpType="GYS"/>
  153. </template>
  154. <template slot-scope="scope" slot="menu">
  155. <el-button
  156. type="text"
  157. icon="el-icon-edit"
  158. size="small"
  159. @click.stop="importStagList(scope.row, scope.index)"
  160. v-if="activeName == 'searchList'"
  161. :disabled=" goodsListSave.findIndex(item => item.id == scope.row.id) !== -1 "
  162. >选择
  163. </el-button>
  164. <el-button
  165. type="text"
  166. icon="el-icon-delete"
  167. size="small"
  168. @click.stop="removeStagList(scope.row, scope.index)"
  169. v-else
  170. >移除
  171. </el-button>
  172. </template>
  173. </avue-crud>
  174. </span>
  175. <span slot="footer" class="dialog-footer">
  176. <el-button @click="dialogVisible = false">取 消</el-button>
  177. <el-button type="primary" :disabled="goodsListSave.length === 0" @click="confirmImport">导 入</el-button>
  178. </span>
  179. </el-dialog>
  180. </div>
  181. </template>
  182. <script>
  183. import option from "./config/mainList.json";
  184. import {getList, remove, gainUser, listXS,generatePurchaseBill} from "@/api/exportTrade/purchaseContract";
  185. import detailPage from "./detailsPage.vue";
  186. import { defaultDate } from "@/util/date";
  187. import { IntegerFormat } from "@/util/validate";
  188. export default {
  189. name: "customerInformation",
  190. data() {
  191. return {
  192. search: {
  193. businesDate: defaultDate()
  194. },
  195. dialogData: [],
  196. goodsListShow: [],
  197. goodsListSave: [],
  198. params:{},
  199. dialogPage: {
  200. pageSize: 20,
  201. currentPage: 1,
  202. total: 0,
  203. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  204. },
  205. activeName: 'searchList',
  206. dialogOption: {},
  207. dialogOptionList: {
  208. searchShow: true,
  209. searchMenuSpan: 16,
  210. border: true,
  211. index: true,
  212. viewBtn: false,
  213. editBtn: false,
  214. delBtn: false,
  215. addBtn: false,
  216. menuWidth: "100",
  217. headerAlign: "center",
  218. searchIcon: true,
  219. searchIndex: 2,
  220. tip: false,
  221. column: [{
  222. label: "销售单号",
  223. prop: "billNo",
  224. search: true,
  225. searchSpan: 8,
  226. overHidden: true
  227. }, {
  228. label: "销售日期",
  229. prop: "businesDate",
  230. searchProp: "businesDateList",
  231. width: 100,
  232. type: "date",
  233. searchSpan: 8,
  234. searchRange: true,
  235. search: true,
  236. searchDefaultTime: ["00:00:00", "23:59:59"],
  237. format: "yyyy-MM-dd",
  238. valueFormat: "yyyy-MM-dd HH:mm:ss",
  239. overHidden: true
  240. }, {
  241. label: "供应商",
  242. prop: "corpName",
  243. searchSpan: 8,
  244. search: true,
  245. overHidden: true
  246. }, {
  247. label: "交货日期",
  248. prop: "plannedDeliveryDate",
  249. searchProp: "plannedDeliveryDateList",
  250. width: 100,
  251. type: "date",
  252. searchSpan: 8,
  253. searchRange: true,
  254. search: true,
  255. searchDefaultTime: ["00:00:00", "23:59:59"],
  256. format: "yyyy-MM-dd",
  257. valueFormat: "yyyy-MM-dd HH:mm:ss",
  258. overHidden: true
  259. }, {
  260. label: "采购员",
  261. prop: "carry",
  262. overHidden: true
  263. }, {
  264. label: "产品名称",
  265. prop: "cname",
  266. overHidden: true
  267. }, {
  268. label: "产品编号",
  269. prop: "code",
  270. overHidden: true
  271. }, {
  272. label: "产品类别",
  273. prop: "priceCategory",
  274. overHidden: true
  275. }, {
  276. label: "产品型号",
  277. prop: "itemType",
  278. overHidden: true
  279. }, {
  280. label: "数量",
  281. prop: "orderQuantity",
  282. overHidden: true
  283. }, {
  284. label: "采购数",
  285. prop: "purchaseQuantity",
  286. overHidden: true
  287. }]
  288. },
  289. dialogVisible: false,
  290. form: {},
  291. option: {},
  292. parentId: 0,
  293. dataList: [],
  294. page: {
  295. pageSize: 20,
  296. currentPage: 1,
  297. total: 0,
  298. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  299. },
  300. totalTwo:0,
  301. show: true,
  302. detailData: {},
  303. loading: false,
  304. selectionList: []
  305. };
  306. },
  307. components: { detailPage },
  308. async created() {
  309. this.option = await this.getColumnData(this.getColumnName(2), option);
  310. this.dialogOption = await this.getColumnData(this.getColumnName(2.1), this.dialogOptionList);
  311. this.getWorkDicts("payment_term").then(res => {
  312. this.findObject(this.option.column, "paymentType").dicData = res.data.data;
  313. });
  314. gainUser().then(res => {
  315. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  316. });
  317. this.option.height = window.innerHeight - 210;
  318. },
  319. filters: {
  320. IntegerFormat(num) {
  321. return IntegerFormat(num);
  322. }
  323. },
  324. activated(){
  325. if (this.$route.query.check){
  326. this.detailData = {
  327. id: this.$route.query.check.billId
  328. };
  329. this.show = false;
  330. this.$store.commit("IN_CG_STATUS");
  331. }
  332. },
  333. methods: {
  334. removeStagList(row, index) {
  335. this.goodsListSave.splice(row.$index, 1);
  336. },
  337. searchCriteriaSwitch(type) {
  338. if (type) {
  339. this.option.height = this.option.height - 139;
  340. } else {
  341. this.option.height = this.option.height + 139;
  342. }
  343. this.$refs.crud.getTableHeight();
  344. },
  345. cellStyle() {
  346. return "padding:0;height:40px;";
  347. },
  348. //删除列表后面的删除按钮触发触发(row, index, done)
  349. rowDel(row, index, done) {
  350. this.$confirm("确定删除数据?", {
  351. confirmButtonText: "确定",
  352. cancelButtonText: "取消",
  353. type: "warning"
  354. }).then(() => {
  355. remove(row.id).then(res => {
  356. if (res.data.code == 200) {
  357. this.$message({
  358. type: "success",
  359. message: "删除成功!"
  360. });
  361. this.onLoad(this.page, this.search);
  362. }
  363. });
  364. });
  365. },
  366. selectionChange(list) {
  367. this.selectionList = list;
  368. },
  369. copyDoc() {
  370. this.selectionList.forEach(e => {
  371. this.detailData = {
  372. id: e.id,
  373. status: "copy"
  374. };
  375. this.show = false;
  376. });
  377. },
  378. copyOrder(id) {
  379. this.show = true;
  380. this.detailData = {
  381. id: id,
  382. status: "copy"
  383. };
  384. this.$nextTick(() => {
  385. this.show = false;
  386. });
  387. },
  388. editOpen(row, status) {
  389. this.detailData = {
  390. id: row.id,
  391. status: status
  392. };
  393. this.show = false;
  394. },
  395. //点击搜索按钮触发
  396. searchChange(params, done) {
  397. if (params.businesDate) {
  398. params.businesStartDate = params.businesDate[0];
  399. params.businesEndDate = params.businesDate[1];
  400. }
  401. if (params.requiredDeliveryDate) {
  402. params.requiredDeliveryStartDate = params.requiredDeliveryDate[0];
  403. params.requiredDeliveryEndDate = params.requiredDeliveryDate[1];
  404. }
  405. delete params.businesDate;
  406. delete params.requiredDeliveryDate;
  407. this.page.currentPage = 1;
  408. this.onLoad(this.page, params);
  409. done();
  410. },
  411. currentChange(val) {
  412. this.page.currentPage = val;
  413. },
  414. sizeChange(val) {
  415. this.page.currentPage = 1;
  416. this.page.pageSize = val;
  417. },
  418. // 标签页切换
  419. tabHandle(data) {
  420. if (data.name == 'searchList') {
  421. this.dialogData = this.goodsListShow;
  422. this.dialogPage.total = this.totalTwo
  423. } else if (data.name == 'importStaging') {
  424. this.goodsListShow = this.dialogData;
  425. this.dialogData = this.goodsListSave;
  426. this.totalTwo = this.dialogPage.total
  427. this.dialogPage.total = 0
  428. }
  429. },
  430. importStagList(row, index) {
  431. this.goodsListSave.push(row);
  432. },
  433. refreshChangeTwo(){
  434. this.dialogOnLoad(this.page);
  435. },
  436. searchChangeTwo(params,done){
  437. done()
  438. this.dialogOnLoad(this.page);
  439. },
  440. //自定义列保存
  441. async saveColumnTwo(ref, option, optionBack, code) {
  442. /**
  443. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  444. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  445. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  446. */
  447. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  448. if (inSave) {
  449. this.$message.success("保存成功");
  450. //关闭窗口
  451. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  452. }
  453. },
  454. //自定义列重置
  455. async resetColumnTwo(ref, option, optionBack, code) {
  456. this[option] = this[optionBack];
  457. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  458. if (inSave) {
  459. this.$message.success("重置成功");
  460. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  461. }
  462. },
  463. confirmImport(){
  464. let ids = this.goodsListSave.map(item => {return item.id})
  465. const loading = this.$loading({
  466. lock: true,
  467. text: '加载中',
  468. spinner: 'el-icon-loading',
  469. background: 'rgba(255,255,255,0.7)'
  470. });
  471. generatePurchaseBill({ids:ids.join(',')}).then(res=>{
  472. this.$message.success("导入成功")
  473. this.detailData = {
  474. form: res.data.data
  475. };
  476. loading.close()
  477. this.dialogVisible = false
  478. setTimeout(() => {
  479. this.show = false;
  480. }, 200);
  481. }).catch(()=>{
  482. loading.close()
  483. })
  484. },
  485. dialogOnLoad(page, params) {
  486. this.dialogLoading = true;
  487. params = {
  488. ...params,
  489. size: page.pageSize,
  490. current: page.currentPage,
  491. ...this.params
  492. }
  493. listXS(params).then(res => {
  494. this.dialogLoading = false
  495. this.dialogData = res.data.data.records
  496. this.dialogPage.total = res.data.data.total
  497. })
  498. },
  499. onLoad(page, params) {
  500. if (this.search.businesDate && this.search.businesDate.length > 0) {
  501. params = {
  502. ...params,
  503. orderStartDate: this.search.businesDate[0],
  504. orderEndDate: this.search.businesDate[1]
  505. };
  506. delete params.businesDate;
  507. }
  508. if (this.search.requiredDeliveryDate && this.search.requiredDeliveryDate.length > 0) {
  509. params = {
  510. ...params,
  511. requiredDeliveryStartDate: this.search.requiredDeliveryDate[0],
  512. requiredDeliveryEndDate: this.search.requiredDeliveryDate[1]
  513. };
  514. delete params.requiredDeliveryDate
  515. }
  516. this.loading = true;
  517. getList(page.currentPage, page.pageSize, params)
  518. .then(res => {
  519. this.dataList = res.data.data.records ? res.data.data.records : [];
  520. this.page.total = res.data.data.total;
  521. })
  522. .finally(() => {
  523. this.loading = false;
  524. });
  525. },
  526. refreshChange() {
  527. this.onLoad(this.page, this.search);
  528. },
  529. newAdd(type) {
  530. this.detailData = {
  531. pageType: type
  532. };
  533. this.show = false;
  534. },
  535. goBack() {
  536. this.detailData = this.$options.data().detailData;
  537. this.show = true;
  538. this.onLoad(this.page, this.search);
  539. },
  540. async saveColumn() {
  541. const inSave = await this.saveColumnData(
  542. this.getColumnName(2),
  543. this.option
  544. );
  545. if (inSave) {
  546. this.$nextTick(() => {
  547. this.$refs.crud.doLayout();
  548. });
  549. this.$message.success("保存成功");
  550. //关闭窗口
  551. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  552. }
  553. },
  554. async resetColumn() {
  555. this.option = option;
  556. const inSave = await this.delColumnData(this.getColumnName(2), option);
  557. if (inSave) {
  558. this.$nextTick(() => {
  559. this.$refs.crud.doLayout();
  560. });
  561. this.$message.success("重置成功");
  562. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  563. }
  564. }
  565. },
  566. watch: {
  567. option: function() {
  568. this.search.businesDate = defaultDate();
  569. },
  570. dialogVisible:function (){
  571. this.goodsListShow = []
  572. this.goodsListSave = []
  573. this.totalTwo = 0
  574. }
  575. }
  576. };
  577. </script>
  578. <style scoped>
  579. ::v-deep .select-component {
  580. display: flex;
  581. }
  582. .page-crad ::v-deep .basic-container__card {
  583. height: 94.2vh;
  584. }
  585. </style>