index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. id="out-table"
  9. :header-cell-class-name="headerClassName"
  10. :before-open="beforeOpen"
  11. v-model="form"
  12. ref="crud"
  13. @row-update="rowUpdate"
  14. @row-save="rowSave"
  15. @row-del="rowDel"
  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. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 308)"
  23. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 308)"
  24. @on-load="onLoad">
  25. <template slot="balanceCycleName" slot-scope="scope">
  26. <avue-text-ellipsis :text="scope.row.balanceCycleName" :height="30" use-tooltip placement="top">
  27. <small slot="more">...</small>
  28. </avue-text-ellipsis>
  29. </template>
  30. <template slot="balanceCycleDescribe" slot-scope="scope">
  31. <avue-text-ellipsis :text="scope.row.balanceCycleDescribe" :height="30" use-tooltip placement="top">
  32. <small slot="more">...</small>
  33. </avue-text-ellipsis>
  34. </template>
  35. <template slot="remarks" slot-scope="scope">
  36. <avue-text-ellipsis :text="scope.row.remarks" :height="30" use-tooltip placement="top">
  37. <small slot="more">...</small>
  38. </avue-text-ellipsis>
  39. </template>
  40. <template slot="menuLeft">
  41. <el-button type="danger"
  42. size="small"
  43. icon="el-icon-delete"
  44. plain
  45. @click="handleDelete">删 除
  46. </el-button>
  47. </template>
  48. </avue-crud>
  49. </basic-container>
  50. </template>
  51. <script>
  52. import {
  53. balancecycleList,
  54. balancecycleDetail,
  55. balancecycleSubmit,
  56. balancecycleRemove,
  57. } from "@/api/iosBasicData/balancecycle";
  58. import {mapGetters} from "vuex";
  59. export default {
  60. data() {
  61. return {
  62. form: {},
  63. query: {},
  64. loading: true,
  65. page: {
  66. pageSize: 10,
  67. currentPage: 1,
  68. total: 0
  69. },
  70. selectionList: [],
  71. option:{},
  72. optionBack: {
  73. height:'auto',
  74. calcHeight: 30,
  75. tip: false,
  76. searchShow: true,
  77. searchMenuSpan: 6,
  78. border: true,
  79. index: true,
  80. viewBtn: true,
  81. selection: true,
  82. dialogClickModal: false,
  83. labelWidth:120,
  84. column: [
  85. {
  86. label: "结算周期类型",
  87. prop: "balanceCycleType",
  88. width: "140",
  89. search: true,
  90. rules: [{
  91. required: true,
  92. message: "请输入结算周期类型",
  93. trigger: "blur"
  94. }]
  95. },
  96. {
  97. label: "中文名称",
  98. prop: "balanceCycleName",
  99. width: "180",
  100. search: true,
  101. rules: [{
  102. required: true,
  103. message: "请输入中文名称",
  104. trigger: "blur"
  105. }]
  106. },
  107. {
  108. label: "结算周期描述",
  109. prop: "balanceCycleDescribe",
  110. width: "240",
  111. search: true,
  112. rules: [{
  113. required: true,
  114. message: "请输入结算周期描述",
  115. trigger: "blur"
  116. }]
  117. },
  118. {
  119. label: "状态",
  120. prop: "status",
  121. type:'select',
  122. dicData:[{
  123. label:'启用',
  124. value:0
  125. },{
  126. label:'停用',
  127. value:1
  128. }],
  129. value:0
  130. },
  131. {
  132. label: "是否已删除(0 否 1是)",
  133. prop: "isDeleted",
  134. hide:true,
  135. display:false,
  136. },
  137. {
  138. label: "备注",
  139. prop: "remarks",
  140. width: "180",
  141. span:24,
  142. type: 'textarea',
  143. width: "180",
  144. slot: true,
  145. minRows: 3,
  146. },
  147. {
  148. label: "创建人",
  149. prop: "createUserName",
  150. display:false,
  151. },
  152. {
  153. label: "创建部门",
  154. prop: "createDeptName",
  155. display:false,
  156. },
  157. {
  158. label: "创建时间",
  159. prop: "createTime",
  160. width: "160",
  161. display:false,
  162. },
  163. {
  164. label: "修改人",
  165. prop: "updateUserName",
  166. display:false,
  167. },
  168. {
  169. label: "修改时间",
  170. prop: "updateTime",
  171. width: "160",
  172. display:false,
  173. },
  174. ]
  175. },
  176. data: []
  177. };
  178. },
  179. computed: {
  180. ...mapGetters(["permission"]),
  181. permissionList() {
  182. return {
  183. // addBtn: this.vaildData(this.permission.balancecycle_add, false),
  184. // viewBtn: this.vaildData(this.permission.balancecycle_view, false),
  185. // delBtn: this.vaildData(this.permission.balancecycle_delete, false),
  186. // editBtn: this.vaildData(this.permission.balancecycle_edit, false)
  187. };
  188. },
  189. ids() {
  190. let ids = [];
  191. this.selectionList.forEach(ele => {
  192. ids.push(ele.id);
  193. });
  194. return ids.join(",");
  195. }
  196. },
  197. async created() {
  198. this.option = await this.getColumnData(this.getColumnName(308), this.optionBack);
  199. },
  200. methods: {
  201. rowSave(row, done, loading) {
  202. balancecycleSubmit(row).then(() => {
  203. this.onLoad(this.page);
  204. this.$message({
  205. type: "success",
  206. message: "操作成功!"
  207. });
  208. done();
  209. }, error => {
  210. loading();
  211. window.console.log(error);
  212. });
  213. },
  214. rowUpdate(row, index, done, loading) {
  215. balancecycleSubmit(row).then(() => {
  216. this.onLoad(this.page);
  217. this.$message({
  218. type: "success",
  219. message: "操作成功!"
  220. });
  221. done();
  222. }, error => {
  223. loading();
  224. console.log(error);
  225. });
  226. },
  227. rowDel(row) {
  228. this.$confirm("确定将选择数据删除?", {
  229. confirmButtonText: "确定",
  230. cancelButtonText: "取消",
  231. type: "warning"
  232. })
  233. .then(() => {
  234. return balancecycleRemove(row.id);
  235. })
  236. .then(() => {
  237. this.onLoad(this.page);
  238. this.$message({
  239. type: "success",
  240. message: "操作成功!"
  241. });
  242. });
  243. },
  244. handleDelete() {
  245. if (this.selectionList.length === 0) {
  246. this.$message.warning("请选择至少一条数据");
  247. return;
  248. }
  249. this.$confirm("确定将选择数据删除?", {
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消",
  252. type: "warning"
  253. })
  254. .then(() => {
  255. return balancecycleRemove(this.ids);
  256. })
  257. .then(() => {
  258. this.onLoad(this.page);
  259. this.$message({
  260. type: "success",
  261. message: "操作成功!"
  262. });
  263. this.$refs.crud.toggleSelection();
  264. });
  265. },
  266. beforeOpen(done, type) {
  267. if (["edit", "view"].includes(type)) {
  268. balancecycleDetail(this.form.id).then(res => {
  269. this.form = res.data.data;
  270. });
  271. }
  272. done();
  273. },
  274. searchReset() {
  275. this.query = {};
  276. this.onLoad(this.page);
  277. },
  278. searchChange(params, done) {
  279. this.query = params;
  280. this.page.currentPage = 1;
  281. this.onLoad(this.page, params);
  282. done();
  283. },
  284. selectionChange(list) {
  285. this.selectionList = list;
  286. },
  287. selectionClear() {
  288. this.selectionList = [];
  289. this.$refs.crud.toggleSelection();
  290. },
  291. currentChange(currentPage){
  292. this.page.currentPage = currentPage;
  293. },
  294. sizeChange(pageSize){
  295. this.page.pageSize = pageSize;
  296. },
  297. refreshChange() {
  298. this.onLoad(this.page, this.query);
  299. },
  300. onLoad(page, params = {}) {
  301. this.loading = true;
  302. balancecycleList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  303. const data = res.data.data;
  304. this.page.total = data.total;
  305. this.data = data.records;
  306. this.loading = false;
  307. this.selectionClear();
  308. });
  309. },
  310. //自定义列保存
  311. async saveColumnTwo(ref, option, optionBack, code) {
  312. /**
  313. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  314. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  315. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  316. */
  317. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  318. if (inSave) {
  319. this.$message.success("保存成功");
  320. //关闭窗口
  321. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  322. }
  323. },
  324. //自定义列重置
  325. async resetColumnTwo(ref, option, optionBack, code) {
  326. this[option] = this[optionBack];
  327. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  328. if (inSave) {
  329. this.$message.success("重置成功");
  330. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  331. }
  332. },
  333. // 更改表格颜色
  334. headerClassName(tab){
  335. //颜色间隔
  336. let back = ""
  337. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  338. if (tab.columnIndex % 2 === 0) {
  339. back = "back-one"
  340. } else if (tab.columnIndex % 2 === 1) {
  341. back = "back-two"
  342. }
  343. }
  344. return back;
  345. },
  346. }
  347. };
  348. </script>
  349. <style scoped>
  350. ::v-deep#out-table .back-one {
  351. background: #ecf5ff !important;
  352. }
  353. ::v-deep#out-table .back-two {
  354. background: #ecf5ff !important;
  355. }
  356. </style>