index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <div>
  3. <basic-container v-show="isShow">
  4. <avue-crud :option="option" :data="dataList" ref="crud" v-model="form" :page.sync="page" :search.sync="search"
  5. :table-loading="loading" @row-del="rowDel" @row-update="rowUpdate" :before-open="beforeOpen"
  6. :before-close="beforeClose" @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
  7. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  8. @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad" @saveColumn="saveColumn"
  9. @resetColumn="resetColumn" @search-criteria-switch="searchCriteriaSwitch" :cell-style="cellStyle">
  10. <template slot="menuLeft" slot-scope="{size}">
  11. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制单据</el-button>
  12. <el-button type="info" :size="size" icon="el-icon-printer" :loading="exportLoading" @click.stop="statement">
  13. 报表打印</el-button>
  14. <el-button type="warning" size="small" icon="el-icon-top" @click.stop="openExport()">导出</el-button>
  15. </template>
  16. <template slot-scope="scope" slot="orgOrderNo">
  17. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row, scope.index)">{{
  18. scope.row.orgOrderNo
  19. }}</span>
  20. </template>
  21. <template slot="corpIdSearch">
  22. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  23. </template>
  24. <template slot="salesCompanySearch">
  25. <!-- <select-component v-model="search.salesCompany" :configuration="configuration"></select-component>-->
  26. <crop-select v-model="search.salesCompany" corpType="GS"></crop-select>
  27. </template>
  28. <template slot-scope="scope" slot="corpId">
  29. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row, scope.index)">{{
  30. scope.row.corpsName
  31. }}</span>
  32. </template>
  33. <template slot-scope="scope" slot="salesCompany">
  34. {{ scope.row.salesCompanyName }}
  35. </template>
  36. <template slot="storageIdSearch">
  37. <warehouseSelect v-model="search.storageId" :configuration="configurationWarehouse"></warehouseSelect>
  38. </template>
  39. <template slot-scope="scope" slot="storageId">
  40. {{ scope.row.storageName }}
  41. </template>
  42. <template slot-scope="scope" slot="createUser">
  43. {{ scope.row.createUserName }}
  44. </template>
  45. <template slot-scope="scope" slot="menu">
  46. <!-- <el-button-->
  47. <!-- type="text"-->
  48. <!-- icon="el-icon-edit"-->
  49. <!-- size="small"-->
  50. <!-- @click.stop="editOpen(scope.row,scope.index)"-->
  51. <!-- >编辑-->
  52. <!-- </el-button>-->
  53. <el-button type="text" icon="el-icon-delete" size="small"
  54. :disabled="scope.row.deliveryStatus === '已发货' || scope.row.deliveryStatus === '已到货'"
  55. @click.stop="rowDel(scope.row, scope.index)">删除
  56. </el-button>
  57. </template>
  58. </avue-crud>
  59. </basic-container>
  60. <detail-page ref="detail" @goBack="goBack" :detailData="detailData" v-if="!isShow"></detail-page>
  61. <report-dialog :switchDialog="switchDialog" :searchValue="statementData" reportName="国内贸易-客户确认"
  62. @onClose="onClose()"></report-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. import option from "./configuration/mainList.json";
  67. import { customerList, typeSave, deleteDetails } from "@/api/basicData/deliveryNotice"
  68. import detailPage from "./detailsPageEdit";
  69. import { defaultDate } from "@/util/date";
  70. import reportDialog from "@/components/report-dialog/main";
  71. import { gainUser } from "@/api/basicData/customerInquiry";
  72. import {getToken} from "@/util/auth";
  73. export default {
  74. name: "customerInformation",
  75. components: {
  76. detailPage,
  77. reportDialog
  78. },
  79. data() {
  80. return {
  81. configuration: {
  82. multipleChoices: false,
  83. multiple: false,
  84. collapseTags: false,
  85. placeholder: "请点击右边按钮选择",
  86. dicData: [],
  87. },
  88. configurationWarehouse: {
  89. multipleChoices: false,
  90. multiple: false,
  91. collapseTags: false,
  92. placeholder: "请点击右边按钮选择",
  93. dicData: [],
  94. },
  95. form: {},
  96. search: {},
  97. loading: false,
  98. option: {},
  99. parentId: 0,
  100. dataList: [],
  101. page: {
  102. pageSize: 10,
  103. currentPage: 1,
  104. total: 0,
  105. pageSizes: [10, 50, 100, 200, 300]
  106. },
  107. // 非单个禁用
  108. single: true,
  109. // 非多个禁用
  110. multiple: true,
  111. selection: [],
  112. isShow: true,
  113. detailData: {},
  114. switchDialog: false, // 报表弹窗
  115. exportLoading: false,
  116. statementData: {},
  117. }
  118. },
  119. async created() {
  120. // this.search.businessDate = defaultDate(1)
  121. this.search.createTime = defaultDate(3)
  122. this.option = option
  123. // this.option = await this.getColumnData(this.getColumnName(20), option);
  124. gainUser().then(res => {
  125. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  126. })
  127. let i = 0;
  128. this.option.column.forEach(item => {
  129. if (item.search) i++
  130. })
  131. if (i % 3 !== 0) {
  132. const num = 3 - Number(i % 3)
  133. this.option.searchMenuSpan = num * 8;
  134. this.option.searchMenuPosition = "right";
  135. }
  136. this.option.column.forEach(item => {
  137. if (item.pickerOptions) {
  138. item.pickerOptions = {
  139. shortcuts: [{
  140. text: '最近一周',
  141. onClick(picker) {
  142. const end = new Date();
  143. const start = new Date();
  144. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  145. picker.$emit('pick', [start, end]);
  146. }
  147. }, {
  148. text: '最近一个月',
  149. onClick(picker) {
  150. const end = new Date();
  151. const start = new Date();
  152. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  153. picker.$emit('pick', [start, end]);
  154. }
  155. }, {
  156. text: '最近三个月',
  157. onClick(picker) {
  158. const end = new Date();
  159. const start = new Date();
  160. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  161. picker.$emit('pick', [start, end]);
  162. }
  163. }]
  164. }
  165. }
  166. })
  167. },
  168. activated() {
  169. // this.isShow = true;
  170. setTimeout(() => {
  171. if (this.$route.query.form) {
  172. this.detailData = {
  173. form: this.$route.query.form,
  174. };
  175. this.$store.commit("IN_IN_DETAIL");
  176. this.isShow = false;
  177. }
  178. }, 100);
  179. },
  180. methods: {
  181. cellStyle() {
  182. return "padding:0;height:40px;";
  183. },
  184. searchCriteriaSwitch(type) {
  185. if (type) {
  186. this.option.height = this.option.height - 140
  187. } else {
  188. this.option.height = this.option.height + 140
  189. }
  190. this.$refs.crud.getTableHeight()
  191. },
  192. //删除列表后面的删除按钮触发触发(row, index, done)
  193. rowDel(row, index, done) {
  194. this.$confirm("确定将选择数据删除?", {
  195. confirmButtonText: "确定",
  196. cancelButtonText: "取消",
  197. type: "warning"
  198. }).then(() => {
  199. return deleteDetails(row.id);
  200. }).then(() => {
  201. this.$message({
  202. type: "success",
  203. message: "操作成功!"
  204. });
  205. this.page.currentPage = 1;
  206. this.onLoad(this.page, { parentId: 0 });
  207. });
  208. },
  209. //修改时的修改按钮点击触发
  210. rowUpdate(row, index, done, loading) {
  211. typeSave(row).then(() => {
  212. this.$message({
  213. type: "success",
  214. message: "操作成功!"
  215. });
  216. // 数据回调进行刷新
  217. done(row);
  218. }, error => {
  219. window.console.log(error);
  220. loading();
  221. });
  222. },
  223. //新增修改时保存触发
  224. rowSave(row, done, loading) {
  225. typeSave(row).then(res => {
  226. done()
  227. })
  228. },
  229. //查询全部
  230. initData() {
  231. customerList().then(res => {
  232. const column = this.findObject(this.option.column, "parentId");
  233. column.dicData = res.data.data.records;
  234. });
  235. },
  236. //新增子项触发
  237. handleAdd(row) {
  238. this.parentId = row.id;
  239. const column = this.findObject(this.option.column, "parentId");
  240. column.value = row.id;
  241. column.addDisabled = true;
  242. this.$refs.crud.rowAdd();
  243. },
  244. //查看跳转页面
  245. beforeOpenPage(row, index) {
  246. const data = {
  247. moduleName: 'fh',
  248. tableName: 'business_delivery',
  249. billId: row.id,
  250. no: localStorage.getItem('browserID')
  251. }
  252. this.checkLock(data).then(res => {
  253. if (res.data.code == 200) {
  254. this.onLock(data).then(response => {
  255. })
  256. this.detailData = {
  257. seeDisabled: true,
  258. id: row.id,
  259. };
  260. this.isShow = false;
  261. this.$store.commit("IN_IN_DETAIL");
  262. }
  263. }).catch(err => {
  264. this.detailData = {
  265. id: row.id,
  266. seeDisabled: true,
  267. opDisabled: true
  268. };
  269. this.isShow = false;
  270. this.$store.commit("IN_IN_DETAIL");
  271. })
  272. },
  273. //新增跳转页面
  274. beforeOpen(row, index) {
  275. this.detailData = {
  276. id: row.id,
  277. };
  278. this.isShow = false;
  279. this.$store.commit("IN_IN_DETAIL");
  280. },
  281. editOpen(row, index) {
  282. this.detailData = {
  283. id: row.id,
  284. };
  285. this.isShow = false;
  286. this.$store.commit("IN_IN_DETAIL");
  287. },
  288. // 复制新单
  289. copyOrder() {
  290. const id = this.selection[0].id;
  291. this.detailData = {
  292. copyId: id,
  293. };
  294. this.isShow = false;
  295. this.$store.commit("IN_IN_DETAIL");
  296. },
  297. //点击新增时触发
  298. beforeClose(done) {
  299. this.parentId = "";
  300. const column = this.findObject(this.option.column, "parentId");
  301. column.value = "";
  302. column.addDisabled = false;
  303. done();
  304. },
  305. //点击搜索按钮触发
  306. searchChange(params, done) {
  307. if (params.businessDate) {
  308. params.businessStartDate = params.businessDate[0] + " " + "00:00:00"
  309. params.businessEndDate = params.businessDate[1] + " " + "23:59:59"
  310. this.$delete(params, 'businessDate')
  311. }
  312. if (params.createTime) {
  313. params.createStartTime = params.createTime[0] + " " + "00:00:00"
  314. params.createEndTime = params.createTime[1] + " " + "23:59:59"
  315. this.$delete(params, 'createTime')
  316. }
  317. this.page.currentPage = 1;
  318. this.onLoad(this.page, params);
  319. done()
  320. },
  321. searchReset() {
  322. // this.configuration.dicData = []
  323. },
  324. selectionChange(list) {
  325. this.selection = list;
  326. this.single = list.length !== 1;
  327. },
  328. currentChange(currentPage) {
  329. this.page.currentPage = currentPage;
  330. },
  331. sizeChange(pageSize) {
  332. this.page.pageSize = pageSize;
  333. },
  334. refreshChange() {
  335. this.page.currentPage = 1;
  336. this.onLoad(this.page, this.search);
  337. },
  338. onLoad(page, params) {
  339. if (this.search.businessDate) {
  340. params = {
  341. ...params,
  342. businessStartDate: this.search.businessDate[0] + " " + "00:00:00",
  343. businessEndDate: this.search.businessDate[1] + " " + "23:59:59",
  344. }
  345. this.$delete(params, 'businessDate')
  346. }
  347. if (this.search.createTime) {
  348. params = {
  349. ...params,
  350. createStartDate: this.search.createTime[0] + " " + "00:00:00",
  351. createEndDate: this.search.createTime[1] + " " + "23:59:59",
  352. }
  353. this.$delete(params, 'createTime')
  354. }
  355. let data = this.gobackSearch(params)
  356. let queryParams = Object.assign({}, data, {
  357. size: page.pageSize,
  358. current: page.currentPage,
  359. billType: "FH"
  360. })
  361. this.loading = true;
  362. customerList(queryParams).then(res => {
  363. this.dataList = res.data.data.records
  364. this.page.total = res.data.data.total
  365. this.option.height = window.innerHeight - 240;
  366. }).finally(() => {
  367. this.loading = false;
  368. })
  369. },
  370. //树桩列点击展开触发
  371. treeLoad(tree, treeNode, resolve) {
  372. const parentId = tree.id;
  373. customerList({ parentId: parentId }).then(res => {
  374. resolve(res.data.data.records);
  375. });
  376. },
  377. goBack() {
  378. this.detailData = this.$options.data().detailData
  379. if (this.$route.query.form) {
  380. this.$router.$avueRouter.closeTag();
  381. this.$router.push({
  382. path: "/businessManagement/deliveryNotice/index"
  383. });
  384. }
  385. this.isShow = true;
  386. this.$store.commit("IN_OUT_DETAIL");
  387. this.onLoad(this.page, this.search)
  388. },
  389. gobackSearch(params) {
  390. params = Object.assign({}, this.search)
  391. if (params.businessDate && params.businessDate != '') {
  392. params.businessStartDate = params.businessDate[0] + " " + "00:00:00"
  393. params.businessEndDate = params.businessDate[1] + " " + "23:59:59"
  394. this.$delete(params, 'businessDate')
  395. }
  396. if (params.createTime && params.createTime != '') {
  397. params.createStartTime = params.createTime[0] + " " + "00:00:00"
  398. params.createEndTime = params.createTime[1] + " " + "23:59:59"
  399. this.$delete(params, 'createTime')
  400. }
  401. if (params.arrivalTime && params.arrivalTime != '') {
  402. params.arrivalStartTime = params.arrivalTime[0] + " " + "00:00:00"
  403. params.arrivalEndTime = params.arrivalTime[1] + " " + "23:59:59"
  404. this.$delete(params, 'arrivalTime')
  405. }
  406. return params
  407. },
  408. //列保存触发
  409. async saveColumn() {
  410. /**
  411. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  412. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  413. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  414. */
  415. const inSave = await this.saveColumnData(
  416. this.getColumnName(20),
  417. this.option
  418. );
  419. if (inSave) {
  420. this.$message.success("保存成功");
  421. //关闭窗口
  422. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  423. this.$nextTick(() => {
  424. this.$refs.crud.doLayout()
  425. })
  426. }
  427. },
  428. async resetColumn() {
  429. this.option = option;
  430. const inSave = await this.delColumnData(
  431. this.getColumnName(20),
  432. option
  433. );
  434. if (inSave) {
  435. this.$nextTick(() => {
  436. this.$refs.crud.doLayout()
  437. })
  438. this.$message.success("重置成功");
  439. //关闭窗口
  440. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  441. }
  442. },
  443. statement() {
  444. this.statementData = { ...this.search }
  445. if (this.statementData.createTime && this.statementData.createTime != '') {
  446. this.statementData.createStartTime = this.statementData.createTime[0] + " " + "00:00:00"
  447. this.statementData.createEndTime = this.statementData.createTime[1] + " " + "23:59:59"
  448. } else {
  449. this.statementData.createStartTime = ""
  450. this.statementData.createEndTime = ""
  451. }
  452. if (this.statementData.businessDate && this.statementData.businessDate != '') {
  453. this.statementData.businessStartDate = this.statementData.businessDate[0] + " " + "00:00:00"
  454. this.statementData.businessEndDate = this.statementData.businessDate[1] + " " + "23:59:59"
  455. } else {
  456. this.statementData.businessStartDate = ""
  457. this.statementData.businessEndDate = ""
  458. }
  459. this.$delete(this.statementData, 'createTime')
  460. this.$delete(this.statementData, 'businessDate')
  461. this.switchDialog = !this.switchDialog;
  462. },
  463. openExport(){
  464. let params = Object.assign({}, this.search)
  465. if (params.businessDate && params.businessDate != '') {
  466. params.businessStartDate = params.businessDate[0] + " " + "00:00:00"
  467. params.businessEndDate = params.businessDate[1] + " " + "23:59:59"
  468. this.$delete(params, 'businessDate')
  469. }
  470. if (params.createTime && params.createTime != '') {
  471. params.createStartTime = params.createTime[0] + " " + "00:00:00"
  472. params.createEndTime = params.createTime[1] + " " + "23:59:59"
  473. this.$delete(params, 'createTime')
  474. }
  475. if (params.arrivalTime && params.arrivalTime != '') {
  476. params.arrivalStartTime = params.arrivalTime[0] + " " + "00:00:00"
  477. params.arrivalEndTime = params.arrivalTime[1] + " " + "23:59:59"
  478. this.$delete(params, 'arrivalTime')
  479. }
  480. const routeData = this.$router.resolve({
  481. path: '/api/blade-deliver-goods/delivery/saleDeliveryExport', //跳转目标窗口的地址
  482. query: {
  483. ...params //括号内是要传递给新窗口的参数
  484. }
  485. })
  486. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  487. },
  488. onClose(val) {
  489. this.switchDialog = val;
  490. },
  491. }
  492. }
  493. </script>
  494. <style scoped>
  495. </style>