index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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" :option="dialogOption"
  136. :page.sync="dialogPage"
  137. :search.sync="params"
  138. ref="dialogCrud"
  139. @refresh-change="refreshChangeTwo"
  140. @on-load="dialogOnLoad">
  141. <template slot="menuLeft">
  142. <el-tabs v-model="activeName" @tab-click="tabHandle">
  143. <el-tab-pane label="查询结果" name="searchList"/>
  144. <el-tab-pane label="已选定数据" name="importStaging"/>
  145. </el-tabs>
  146. </template>
  147. <template slot-scope="scope" slot="menu">
  148. <el-button
  149. type="text"
  150. icon="el-icon-edit"
  151. size="small"
  152. @click.stop="importStagList(scope.row, scope.index)"
  153. v-if="activeName == 'searchList'"
  154. :disabled=" goodsListSave.findIndex(item => item.id == scope.row.id) !== -1 "
  155. >选择
  156. </el-button>
  157. <el-button
  158. type="text"
  159. icon="el-icon-delete"
  160. size="small"
  161. @click.stop="removeStagList(scope.row, scope.index)"
  162. v-else
  163. >移除
  164. </el-button>
  165. </template>
  166. </avue-crud>
  167. </span>
  168. <span slot="footer" class="dialog-footer">
  169. <el-button @click="dialogVisible = false">取 消</el-button>
  170. <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  171. </span>
  172. </el-dialog>
  173. </div>
  174. </template>
  175. <script>
  176. import option from "./config/mainList.json";
  177. import {getList, remove, gainUser, listXS} from "@/api/exportTrade/purchaseContract";
  178. import detailPage from "./detailsPage.vue";
  179. import { defaultDate } from "@/util/date";
  180. import { IntegerFormat } from "@/util/validate";
  181. export default {
  182. name: "customerInformation",
  183. data() {
  184. return {
  185. search: {
  186. businesDate: defaultDate()
  187. },
  188. dialogData: [],
  189. goodsListShow: [],
  190. goodsListSave: [],
  191. params:{},
  192. dialogPage: {
  193. pageSize: 20,
  194. currentPage: 1,
  195. total: 0,
  196. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  197. },
  198. activeName: 'searchList',
  199. dialogOption: {
  200. searchShow: true,
  201. searchMenuSpan: 16,
  202. border: true,
  203. index: true,
  204. viewBtn: false,
  205. editBtn: false,
  206. delBtn: false,
  207. addBtn: false,
  208. menuWidth: "100",
  209. headerAlign: "center",
  210. searchIcon: true,
  211. searchIndex: 2,
  212. tip: false,
  213. column: [{
  214. label: "销售单号",
  215. prop: "orderNo",
  216. search:false,
  217. overHidden: true
  218. }, {
  219. label: "销售日期",
  220. prop: "businesDate",
  221. overHidden: true
  222. }, {
  223. label: "供应商",
  224. prop: "corpId",
  225. overHidden: true
  226. }, {
  227. label: "交货日期",
  228. prop: "corpId",
  229. overHidden: true
  230. }, {
  231. label: "采购员",
  232. prop: "corpId",
  233. overHidden: true
  234. }, {
  235. label: "产品名称",
  236. prop: "corpId",
  237. overHidden: true
  238. }, {
  239. label: "产品编号",
  240. prop: "corpId",
  241. overHidden: true
  242. }, {
  243. label: "产品类别",
  244. prop: "corpId",
  245. overHidden: true
  246. }, {
  247. label: "产品型号",
  248. prop: "corpId",
  249. overHidden: true
  250. }, {
  251. label: "数量",
  252. prop: "corpId",
  253. overHidden: true
  254. }, {
  255. label: "采购数",
  256. prop: "corpId",
  257. overHidden: true
  258. }]
  259. },
  260. dialogVisible: false,
  261. form: {},
  262. option: {},
  263. parentId: 0,
  264. dataList: [],
  265. page: {
  266. pageSize: 20,
  267. currentPage: 1,
  268. total: 0,
  269. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  270. },
  271. totalTwo:0,
  272. show: true,
  273. detailData: {},
  274. loading: false,
  275. selectionList: []
  276. };
  277. },
  278. components: { detailPage },
  279. async created() {
  280. this.option = await this.getColumnData(this.getColumnName(2), option);
  281. this.getWorkDicts("payment_term").then(res => {
  282. this.findObject(this.option.column, "paymentType").dicData =
  283. res.data.data;
  284. });
  285. gainUser().then(res => {
  286. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  287. });
  288. this.option.height = window.innerHeight - 210;
  289. },
  290. filters: {
  291. IntegerFormat(num) {
  292. return IntegerFormat(num);
  293. }
  294. },
  295. methods: {
  296. removeStagList(row, index) {
  297. this.goodsListSave.splice(row.$index, 1);
  298. },
  299. searchCriteriaSwitch(type) {
  300. if (type) {
  301. this.option.height = this.option.height - 139;
  302. } else {
  303. this.option.height = this.option.height + 139;
  304. }
  305. this.$refs.crud.getTableHeight();
  306. },
  307. cellStyle() {
  308. return "padding:0;height:40px;";
  309. },
  310. //删除列表后面的删除按钮触发触发(row, index, done)
  311. rowDel(row, index, done) {
  312. this.$confirm("确定删除数据?", {
  313. confirmButtonText: "确定",
  314. cancelButtonText: "取消",
  315. type: "warning"
  316. }).then(() => {
  317. remove(row.id).then(res => {
  318. if (res.data.code == 200) {
  319. this.$message({
  320. type: "success",
  321. message: "删除成功!"
  322. });
  323. this.onLoad(this.page, this.search);
  324. }
  325. });
  326. });
  327. },
  328. selectionChange(list) {
  329. this.selectionList = list;
  330. },
  331. copyDoc() {
  332. this.selectionList.forEach(e => {
  333. this.detailData = {
  334. id: e.id,
  335. status: "copy"
  336. };
  337. this.show = false;
  338. });
  339. },
  340. copyOrder(id) {
  341. this.show = true;
  342. this.detailData = {
  343. id: id,
  344. status: "copy"
  345. };
  346. this.$nextTick(() => {
  347. this.show = false;
  348. });
  349. },
  350. editOpen(row, status) {
  351. this.detailData = {
  352. id: row.id,
  353. status: status
  354. };
  355. this.show = false;
  356. },
  357. //点击搜索按钮触发
  358. searchChange(params, done) {
  359. if (params.businesDate) {
  360. params.businesStartDate = params.businesDate[0];
  361. params.businesEndDate = params.businesDate[1];
  362. }
  363. if (params.requiredDeliveryDate) {
  364. params.requiredDeliveryStartDate = params.requiredDeliveryDate[0];
  365. params.requiredDeliveryEndDate = params.requiredDeliveryDate[1];
  366. }
  367. delete params.businesDate;
  368. delete params.requiredDeliveryDate;
  369. this.page.currentPage = 1;
  370. this.onLoad(this.page, params);
  371. done();
  372. },
  373. currentChange(val) {
  374. this.page.currentPage = val;
  375. },
  376. sizeChange(val) {
  377. this.page.currentPage = 1;
  378. this.page.pageSize = val;
  379. },
  380. // 标签页切换
  381. tabHandle(data) {
  382. if (data.name == 'searchList') {
  383. this.dialogData = this.goodsListShow;
  384. this.dialogPage.total = this.totalTwo
  385. } else if (data.name == 'importStaging') {
  386. this.goodsListShow = this.dialogData;
  387. this.dialogData = this.goodsListSave;
  388. this.totalTwo = this.dialogPage.total
  389. this.dialogPage.total = 0
  390. }
  391. },
  392. importStagList(row, index) {
  393. this.goodsListSave.push(row);
  394. },
  395. refreshChangeTwo(){
  396. this.onLoad(this.page);
  397. },
  398. dialogOnLoad(page, params) {
  399. this.dialogLoading = true;
  400. params = {
  401. ...params,
  402. size: page.pageSize,
  403. current: page.currentPage,
  404. ...this.params
  405. }
  406. listXS(params).then(res => {
  407. this.dialogLoading = false
  408. this.dialogData = res.data.data.records
  409. this.dialogPage.total = res.data.data.total
  410. })
  411. },
  412. onLoad(page, params) {
  413. if (this.search.businesDate && this.search.businesDate.length > 0) {
  414. params = {
  415. ...params,
  416. orderStartDate: this.search.businesDate[0],
  417. orderEndDate: this.search.businesDate[1]
  418. };
  419. delete params.businesDate;
  420. }
  421. this.loading = true;
  422. getList(page.currentPage, page.pageSize, params)
  423. .then(res => {
  424. this.dataList = res.data.data.records ? res.data.data.records : [];
  425. this.page.total = res.data.data.total;
  426. })
  427. .finally(() => {
  428. this.loading = false;
  429. });
  430. },
  431. refreshChange() {
  432. this.onLoad(this.page, this.search);
  433. },
  434. newAdd(type) {
  435. this.detailData = {
  436. pageType: type
  437. };
  438. this.show = false;
  439. },
  440. goBack() {
  441. this.detailData = this.$options.data().detailData;
  442. this.show = true;
  443. this.onLoad(this.page, this.search);
  444. },
  445. async saveColumn() {
  446. const inSave = await this.saveColumnData(
  447. this.getColumnName(2),
  448. this.option
  449. );
  450. if (inSave) {
  451. this.$nextTick(() => {
  452. this.$refs.crud.doLayout();
  453. });
  454. this.$message.success("保存成功");
  455. //关闭窗口
  456. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  457. }
  458. },
  459. async resetColumn() {
  460. this.option = option;
  461. const inSave = await this.delColumnData(this.getColumnName(2), option);
  462. if (inSave) {
  463. this.$nextTick(() => {
  464. this.$refs.crud.doLayout();
  465. });
  466. this.$message.success("重置成功");
  467. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  468. }
  469. }
  470. },
  471. watch: {
  472. option: function() {
  473. this.search.businesDate = defaultDate();
  474. },
  475. dialogVisible:function (){
  476. this.goodsListShow = []
  477. this.goodsListSave = []
  478. this.totalTwo = 0
  479. }
  480. }
  481. };
  482. </script>
  483. <style scoped>
  484. ::v-deep .select-component {
  485. display: flex;
  486. }
  487. .page-crad ::v-deep .basic-container__card {
  488. height: 94.2vh;
  489. }
  490. </style>