index.vue 13 KB

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