index.vue 13 KB

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