index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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="GYS"
  37. ></crop-select>
  38. </template>
  39. <template slot-scope="scope" slot="corpId">
  40. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.corpsName }}</span>
  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="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/receipt"
  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. clearable: true,
  108. },
  109. configurationWarehouse: {
  110. multipleChoices: false,
  111. multiple: false,
  112. collapseTags: false,
  113. placeholder: "请点击右边按钮选择",
  114. dicData: [],
  115. clearable: true,
  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(23), 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("DOM_IN_DETAIL");
  191. this.isShow = false;
  192. }
  193. }, 100);
  194. },
  195. methods: {
  196. //删除列表后面的删除按钮触发触发(row, index, done)
  197. rowDel(row, index, done) {
  198. this.$confirm("确定将选择数据删除?", {
  199. confirmButtonText: "确定",
  200. cancelButtonText: "取消",
  201. type: "warning"
  202. }).then(() => {
  203. return deleteDetails(row.id);
  204. }).then(() => {
  205. this.$message({
  206. type: "success",
  207. message: "操作成功!"
  208. });
  209. this.page.currentPage = 1;
  210. this.onLoad(this.page, {parentId: 0});
  211. });
  212. },
  213. //修改时的修改按钮点击触发
  214. rowUpdate(row, index, done, loading) {
  215. typeSave(row).then(() => {
  216. this.$message({
  217. type: "success",
  218. message: "操作成功!"
  219. });
  220. // 数据回调进行刷新
  221. done(row);
  222. }, error => {
  223. window.console.log(error);
  224. loading();
  225. });
  226. },
  227. //新增修改时保存触发
  228. rowSave(row, done, loading) {
  229. typeSave(row).then(res => {
  230. console.log(res)
  231. done()
  232. })
  233. },
  234. //查询全部
  235. initData() {
  236. customerList().then(res => {
  237. console.log(this.form);
  238. const column = this.findObject(this.option.column, "parentId");
  239. column.dicData = res.data.data.records;
  240. });
  241. },
  242. //新增子项触发
  243. handleAdd(row) {
  244. this.parentId = row.id;
  245. const column = this.findObject(this.option.column, "parentId");
  246. column.value = row.id;
  247. column.addDisabled = true;
  248. this.$refs.crud.rowAdd();
  249. },
  250. //查看跳转页面
  251. beforeOpenPage(row, index) {
  252. const data = {
  253. moduleName: 'sh',
  254. tableName: 'business_delivery',
  255. billId: row.id,
  256. no: localStorage.getItem('browserID')
  257. }
  258. this.checkLock(data).then(res => {
  259. if (res.data.code == 200) {
  260. this.detailData = {
  261. seeDisabled: true,
  262. id: row.id,
  263. };
  264. this.isShow = false;
  265. this.$store.commit("DOM_IN_DETAIL");
  266. }
  267. }).catch(err => {
  268. this.detailData = {
  269. id: row.id,
  270. seeDisabled: true,
  271. opDisabled: true
  272. };
  273. this.isShow = false;
  274. this.$store.commit("DOM_IN_DETAIL");
  275. })
  276. },
  277. //新增跳转页面
  278. beforeOpen(row, index) {
  279. this.detailData = {
  280. id: row.id,
  281. };
  282. this.isShow = false;
  283. this.$store.commit("DOM_IN_DETAIL");
  284. },
  285. editOpen(row, index) {
  286. this.detailData = {
  287. id: row.id,
  288. };
  289. this.isShow = false;
  290. this.$store.commit("DOM_IN_DETAIL");
  291. },
  292. // 复制新单
  293. copyOrder() {
  294. const id = this.selection[0].id;
  295. this.detailData = {
  296. copyId: id,
  297. };
  298. this.isShow = false;
  299. this.$store.commit("DOM_IN_DETAIL");
  300. },
  301. //点击新增时触发
  302. beforeClose(done) {
  303. this.parentId = "";
  304. const column = this.findObject(this.option.column, "parentId");
  305. column.value = "";
  306. column.addDisabled = false;
  307. done();
  308. },
  309. //点击搜索按钮触发
  310. searchChange(params, done) {
  311. if (params.businessDate) {
  312. this.$set(params, 'businessStartDate', params.businessDate[0]+ " " + "00:00:00")
  313. this.$set(params, 'businessEndDate', params.businessDate[1]+ " " + "23:59:59")
  314. this.$delete(params,'businessDate')
  315. }
  316. if (params.createTime) {
  317. this.$set(params, 'createStartTime', params.createTime[0]+ " " + "00:00:00")
  318. this.$set(params, 'createEndTime', params.createTime[1]+ " " + "23:59:59")
  319. this.$delete(params,'createTime')
  320. }
  321. this.page.currentPage = 1;
  322. this.onLoad(this.page, params);
  323. done()
  324. },
  325. searchReset() {
  326. console.log('1')
  327. },
  328. selectionChange(list) {
  329. this.selection = list;
  330. this.single = list.length !== 1;
  331. },
  332. currentChange(currentPage) {
  333. this.page.currentPage = currentPage;
  334. },
  335. sizeChange(pageSize) {
  336. this.page.pageSize = pageSize;
  337. },
  338. refreshChange() {
  339. this.page.currentPage = 1;
  340. this.onLoad(this.page,this.search);
  341. },
  342. onLoad(page, params) {
  343. let data = this.gobackSearch(params)
  344. let queryParams = Object.assign({}, data, {
  345. size: page.pageSize,
  346. current: page.currentPage,
  347. billType:'SH',
  348. corpsTypeId: this.treeDeptId
  349. })
  350. this.loading = true;
  351. customerList(queryParams).then(res => {
  352. this.dataList = res.data.data.records
  353. this.page.total = res.data.data.total
  354. }).finally(() => {
  355. this.loading = false;
  356. })
  357. },
  358. //树桩列点击展开触发
  359. treeLoad(tree, treeNode, resolve) {
  360. const parentId = tree.id;
  361. customerList({parentId: parentId}).then(res => {
  362. resolve(res.data.data.records);
  363. });
  364. },
  365. goBack() {
  366. this.detailData=this.$options.data().detailData
  367. if (this.$route.query.form) {
  368. this.$router.$avueRouter.closeTag();
  369. this.$router.push({
  370. path: "/businessManagement/receipt/index"
  371. });
  372. }
  373. this.isShow = true;
  374. this.$store.commit("DOM_OUT_DETAIL");
  375. this.onLoad(this.page, this.search)
  376. },
  377. gobackSearch(params) {
  378. params = Object.assign({}, this.search)
  379. if (params.businessDate && params.businessDate != '') {
  380. this.$set(params, 'businessStartDate', params.businessDate[0]+ " " + "00:00:00")
  381. this.$set(params, 'businessEndDate', params.businessDate[1]+ " " + "23:59:59")
  382. this.$delete(params,'businessDate')
  383. }
  384. if (params.createTime && params.createTime != '') {
  385. this.$set(params, 'createStartTime', params.createTime[0]+ " " + "00:00:00")
  386. this.$set(params, 'createEndTime', params.createTime[1]+ " " + "23:59:59")
  387. this.$delete(params,'createTime')
  388. }
  389. return params
  390. },
  391. //列保存触发
  392. async saveColumn() {
  393. /**
  394. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  395. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  396. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  397. */
  398. const inSave = await this.saveColumnData(
  399. this.getColumnName(23),
  400. this.option
  401. );
  402. if (inSave) {
  403. this.$message.success("保存成功");
  404. //关闭窗口
  405. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  406. }
  407. },
  408. async resetColumn() {
  409. this.option = option;
  410. const inSave = await this.delColumnData(
  411. this.getColumnName(23),
  412. option
  413. );
  414. if (inSave) {
  415. this.$message.success("重置成功");
  416. //关闭窗口
  417. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  418. }
  419. },
  420. }
  421. }
  422. </script>
  423. <style scoped>
  424. </style>