index.vue 13 KB

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