index.vue 15 KB

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