index.vue 12 KB

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