index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. activated() {
  115. setTimeout(() => {
  116. if (this.$route.query.check) {
  117. this.isShow = true;
  118. // this.beforeOpenPage({id: this.$route.query.check.billId})
  119. this.detailData = {
  120. id: this.$route.query.check.billId,
  121. check: this.$route.query.check,
  122. auditId: this.$route.query.check.id
  123. };
  124. this.isShow = false;
  125. this.$store.commit("XIAO_SHO_ZHENG_CEKAI");
  126. }
  127. }, 100);
  128. },
  129. methods: {
  130. searchCriteriaSwitch(type){
  131. if (type){
  132. this.option.height = this.option.height - 95
  133. }else {
  134. this.option.height = this.option.height + 95
  135. }
  136. this.$refs.crud.getTableHeight()
  137. },
  138. //删除列表后面的删除按钮触发触发(row, index, done)
  139. rowDel(row, index, done) {
  140. this.$confirm("确定将选择数据删除?", {
  141. confirmButtonText: "确定",
  142. cancelButtonText: "取消",
  143. type: "warning"
  144. }).then(() => {
  145. return deleteDetails(row.id);
  146. }).then(() => {
  147. this.$message({
  148. type: "success",
  149. message: "操作成功!"
  150. });
  151. this.page.currentPage = 1;
  152. this.onLoad(this.page, {parentId: 0});
  153. });
  154. },
  155. //修改时的修改按钮点击触发
  156. rowUpdate(row, index, done, loading) {
  157. typeSave(row).then(() => {
  158. this.$message({
  159. type: "success",
  160. message: "操作成功!"
  161. });
  162. // 数据回调进行刷新
  163. done(row);
  164. }, error => {
  165. window.console.log(error);
  166. loading();
  167. });
  168. },
  169. //新增修改时保存触发
  170. rowSave(row, done, loading) {
  171. typeSave(row).then(res => {
  172. console.log(res)
  173. done()
  174. })
  175. },
  176. //查询全部
  177. initData() {
  178. customerList().then(res => {
  179. console.log(this.form);
  180. const column = this.findObject(this.option.column, "parentId");
  181. column.dicData = res.data.data.records;
  182. });
  183. },
  184. //新增子项触发
  185. handleAdd(row) {
  186. this.parentId = row.id;
  187. const column = this.findObject(this.option.column, "parentId");
  188. column.value = row.id;
  189. column.addDisabled = true;
  190. this.$refs.crud.rowAdd();
  191. },
  192. //查看跳转页面
  193. beforeOpenPage(row, index) {
  194. this.detailData = {
  195. id: row.id,
  196. };
  197. this.isShow = false;
  198. // this.$router.push({
  199. // path: "/salesPolicy_detailsPageEdit",
  200. // query: {id: JSON.stringify(row.id)},
  201. // });
  202. },
  203. //新增跳转页面
  204. beforeOpen(row, index) {
  205. this.detailData = {
  206. id: row.id,
  207. };
  208. this.isShow = false;
  209. // this.$router.push({
  210. // path: "/salesPolicy_detailsPageEdit",
  211. // query: {id: JSON.stringify(row.id)},
  212. // });
  213. },
  214. editOpen(row, index) {
  215. this.detailData = {
  216. id: row.id,
  217. };
  218. this.isShow = false;
  219. // this.$router.push({
  220. // path: "/salesPolicy_detailsPageEdit",
  221. // query: {id: JSON.stringify(row.id)},
  222. // });
  223. },
  224. //点击新增时触发
  225. beforeClose(done) {
  226. this.parentId = "";
  227. const column = this.findObject(this.option.column, "parentId");
  228. column.value = "";
  229. column.addDisabled = false;
  230. done();
  231. },
  232. //点击搜索按钮触发
  233. searchChange(params, done) {
  234. if (params.createTime) {
  235. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  236. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  237. delete params.createTime;
  238. }
  239. if (params.startTime) {
  240. params.dateValidityStart = params.startTime[0]+ " " + "00:00:00"
  241. params.dateValidityEnd = params.startTime[1]+ " " + "23:59:59"
  242. delete params.startTime;
  243. }
  244. this.page.currentPage = 1;
  245. this.onLoad(this.page, params);
  246. done()
  247. },
  248. searchReset() {
  249. console.log('1')
  250. },
  251. selectionChange() {
  252. console.log('1')
  253. },
  254. currentChange() {
  255. console.log('1')
  256. },
  257. sizeChange() {
  258. console.log('1')
  259. },
  260. refreshChange() {
  261. console.log('1')
  262. },
  263. onLoad(page, params = {parentId: 0}) {
  264. let queryParams = Object.assign({}, params, {
  265. size: page.pageSize,
  266. current: page.currentPage,
  267. })
  268. customerList(queryParams).then(res => {
  269. this.dataList = res.data.data.records
  270. this.page.total = res.data.data.total
  271. if (this.page.total) {
  272. this.option.height = window.innerHeight - 240;
  273. }
  274. })
  275. },
  276. //树桩列点击展开触发
  277. treeLoad(tree, treeNode, resolve) {
  278. const parentId = tree.id;
  279. customerList({parentId: parentId}).then(res => {
  280. resolve(res.data.data.records);
  281. });
  282. },
  283. goBack() {
  284. this.detailData=this.$options.data().detailData
  285. this.isShow = true;
  286. },
  287. }
  288. }
  289. </script>
  290. <style scoped>
  291. </style>