index.vue 18 KB

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