index.vue 15 KB

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