index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. @row-del="rowDel"
  11. @row-update="rowUpdate"
  12. :before-open="beforeOpen"
  13. :before-close="beforeClose"
  14. @row-save="rowSave"
  15. @search-change="searchChange"
  16. @search-reset="searchReset"
  17. @selection-change="selectionChange"
  18. @current-change="currentChange"
  19. @size-change="sizeChange"
  20. @refresh-change="refreshChange"
  21. @on-load="onLoad"
  22. @tree-load="treeLoad"
  23. @search-criteria-switch="searchCriteriaSwitch">
  24. <template slot-scope="{}" slot="startTimeSearchLabel">
  25. <span>有效日期:</span>
  26. </template>
  27. <template slot="corpsSearch">
  28. <select-component
  29. v-model="search.corps"
  30. :configuration="configuration"
  31. ></select-component>
  32. </template>
  33. <template slot-scope="scope" slot="corps">
  34. {{ scope.row.corps }}
  35. </template>
  36. <template slot-scope="scope" slot="menu">
  37. <el-button
  38. type="text"
  39. icon="el-icon-view"
  40. size="small"
  41. @click.stop="beforeOpenPage(scope.row,scope.index)"
  42. >查看
  43. </el-button>
  44. <el-button
  45. type="text"
  46. icon="el-icon-edit"
  47. size="small"
  48. @click.stop="editOpen(scope.row,scope.index)"
  49. >编辑
  50. </el-button>
  51. <el-button
  52. type="text"
  53. icon="el-icon-delete"
  54. size="small"
  55. @click.stop="rowDel(scope.row,scope.index)"
  56. :disabled="scope.row.status == 0"
  57. >删除
  58. </el-button>
  59. </template>
  60. </avue-crud>
  61. </basic-container>
  62. <detail-page
  63. ref="detail"
  64. @goBack="goBack"
  65. :detailData="detailData"
  66. v-else
  67. ></detail-page>
  68. </div>
  69. </template>
  70. <script>
  71. import option from "./configuration/mainList.json";
  72. import {customerList, typeSave, deleteDetails} from "@/api/maintenance/salesPolicy";
  73. import detailPage from "./detailsPageEdit";
  74. export default {
  75. name: "customerInformation",
  76. components: {
  77. detailPage
  78. },
  79. data() {
  80. return {
  81. form: {},
  82. option: option,
  83. search: {},
  84. configuration: {
  85. multipleChoices: false,
  86. multiple: false,
  87. collapseTags: false,
  88. placeholder: "请点击右边按钮选择",
  89. dicData: [],
  90. clearable: true
  91. },
  92. parentId: 0,
  93. dataList: [],
  94. page: {
  95. pageSize: 10,
  96. pagerCount: 5,
  97. total: 0,
  98. },
  99. isShow: true,
  100. detailData: {},
  101. }
  102. },
  103. created() {
  104. let i = 0;
  105. this.option.column.forEach(item => {
  106. if (item.search) i++
  107. })
  108. if (i % 3 !== 0){
  109. const num = 3 - Number(i % 3)
  110. this.option.searchMenuSpan = num * 8;
  111. this.option.searchMenuPosition = "right";
  112. }
  113. },
  114. methods: {
  115. searchCriteriaSwitch(type){
  116. if (type){
  117. this.option.height = this.option.height - 95
  118. }else {
  119. this.option.height = this.option.height + 95
  120. }
  121. this.$refs.crud.getTableHeight()
  122. },
  123. //删除列表后面的删除按钮触发触发(row, index, done)
  124. rowDel(row, index, done) {
  125. this.$confirm("确定将选择数据删除?", {
  126. confirmButtonText: "确定",
  127. cancelButtonText: "取消",
  128. type: "warning"
  129. }).then(() => {
  130. return deleteDetails(row.id);
  131. }).then(() => {
  132. this.$message({
  133. type: "success",
  134. message: "操作成功!"
  135. });
  136. this.page.currentPage = 1;
  137. this.onLoad(this.page, {parentId: 0});
  138. });
  139. },
  140. //修改时的修改按钮点击触发
  141. rowUpdate(row, index, done, loading) {
  142. typeSave(row).then(() => {
  143. this.$message({
  144. type: "success",
  145. message: "操作成功!"
  146. });
  147. // 数据回调进行刷新
  148. done(row);
  149. }, error => {
  150. window.console.log(error);
  151. loading();
  152. });
  153. },
  154. //新增修改时保存触发
  155. rowSave(row, done, loading) {
  156. typeSave(row).then(res => {
  157. console.log(res)
  158. done()
  159. })
  160. },
  161. //查询全部
  162. initData() {
  163. customerList().then(res => {
  164. console.log(this.form);
  165. const column = this.findObject(this.option.column, "parentId");
  166. column.dicData = res.data.data.records;
  167. });
  168. },
  169. //新增子项触发
  170. handleAdd(row) {
  171. this.parentId = row.id;
  172. const column = this.findObject(this.option.column, "parentId");
  173. column.value = row.id;
  174. column.addDisabled = true;
  175. this.$refs.crud.rowAdd();
  176. },
  177. //查看跳转页面
  178. beforeOpenPage(row, index) {
  179. this.detailData = {
  180. id: row.id,
  181. };
  182. this.isShow = false;
  183. // this.$router.push({
  184. // path: "/salesPolicy_detailsPageEdit",
  185. // query: {id: JSON.stringify(row.id)},
  186. // });
  187. },
  188. //新增跳转页面
  189. beforeOpen(row, index) {
  190. this.detailData = {
  191. id: row.id,
  192. };
  193. this.isShow = false;
  194. // this.$router.push({
  195. // path: "/salesPolicy_detailsPageEdit",
  196. // query: {id: JSON.stringify(row.id)},
  197. // });
  198. },
  199. editOpen(row, index) {
  200. this.detailData = {
  201. id: row.id,
  202. };
  203. this.isShow = false;
  204. // this.$router.push({
  205. // path: "/salesPolicy_detailsPageEdit",
  206. // query: {id: JSON.stringify(row.id)},
  207. // });
  208. },
  209. //点击新增时触发
  210. beforeClose(done) {
  211. this.parentId = "";
  212. const column = this.findObject(this.option.column, "parentId");
  213. column.value = "";
  214. column.addDisabled = false;
  215. done();
  216. },
  217. //点击搜索按钮触发
  218. searchChange(params, done) {
  219. if (params.createTime) {
  220. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  221. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  222. delete params.createTime;
  223. }
  224. if (params.startTime) {
  225. params.dateValidityStart = params.startTime[0]+ " " + "00:00:00"
  226. params.dateValidityEnd = params.startTime[1]+ " " + "23:59:59"
  227. delete params.startTime;
  228. }
  229. this.page.currentPage = 1;
  230. this.onLoad(this.page, params);
  231. done()
  232. },
  233. searchReset() {
  234. console.log('1')
  235. },
  236. selectionChange() {
  237. console.log('1')
  238. },
  239. currentChange() {
  240. console.log('1')
  241. },
  242. sizeChange() {
  243. console.log('1')
  244. },
  245. refreshChange() {
  246. console.log('1')
  247. },
  248. onLoad(page, params = {parentId: 0}) {
  249. let queryParams = Object.assign({}, params, {
  250. size: page.pageSize,
  251. current: page.currentPage,
  252. })
  253. customerList(queryParams).then(res => {
  254. this.dataList = res.data.data.records
  255. this.page.total = res.data.data.total
  256. if (this.page.total) {
  257. this.option.height = window.innerHeight - 240;
  258. }
  259. })
  260. },
  261. //树桩列点击展开触发
  262. treeLoad(tree, treeNode, resolve) {
  263. const parentId = tree.id;
  264. customerList({parentId: parentId}).then(res => {
  265. resolve(res.data.data.records);
  266. });
  267. },
  268. goBack() {
  269. this.detailData=this.$options.data().detailData
  270. this.isShow = true;
  271. },
  272. }
  273. }
  274. </script>
  275. <style scoped>
  276. </style>