index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <!--费用模板-->
  2. <template>
  3. <div>
  4. <basic-container v-if="isShow">
  5. <avue-crud :option="option"
  6. :table-loading="loading"
  7. :data="data"
  8. :page.sync="page"
  9. :permission="permissionList"
  10. id="out-table"
  11. :header-cell-class-name="headerClassName"
  12. :before-open="beforeOpen"
  13. v-model="form"
  14. ref="crud"
  15. @row-update="rowUpdate"
  16. @row-save="rowSave"
  17. @row-del="rowDel"
  18. @search-change="searchChange"
  19. @search-reset="searchReset"
  20. @selection-change="selectionChange"
  21. @current-change="currentChange"
  22. @size-change="sizeChange"
  23. @refresh-change="refreshChange"
  24. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 303)"
  25. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 303)"
  26. @on-load="onLoad">
  27. <template slot="menuLeft">
  28. <el-button type="primary"
  29. size="small"
  30. icon="el-icon-plus"
  31. @click="addbtnfun()">新增费用模板
  32. </el-button>
  33. <el-button type="danger"
  34. size="small"
  35. icon="el-icon-delete"
  36. plain
  37. @click="handleDelete">删 除
  38. </el-button>
  39. </template>
  40. <template slot-scope="scope" slot="menu">
  41. <el-button
  42. :type="scope.type"
  43. :size="scope.size"
  44. icon="el-icon-edit"
  45. @click.stop="rowCellfun(scope.row, scope.index)"
  46. >编辑
  47. </el-button>
  48. <el-button
  49. :type="scope.type"
  50. :size="scope.size"
  51. icon="el-icon-delete"
  52. @click.stop="rowDel(scope.row, scope.index)"
  53. >删除
  54. </el-button>
  55. </template>
  56. <template slot="remarks" slot-scope="scope">
  57. <avue-text-ellipsis :text="scope.row.remarks" :height="30" use-tooltip placement="top">
  58. <small slot="more">...</small>
  59. </avue-text-ellipsis>
  60. </template>
  61. </avue-crud>
  62. </basic-container>
  63. <fees-templateItems ref="feesTemplateItems" v-if="!isShow" :detailData="detailData" @goBack="goBack"></fees-templateItems>
  64. </div>
  65. </template>
  66. <script>
  67. import {losbfeestemplateList, losbfeestemplateDetail, losbfeestemplateSubmit, losbfeestemplateRemove} from "@/api/iosBasicData/losbfeestemplate.js";
  68. import {mapGetters} from "vuex";
  69. import feesTemplateItems from "@/views/iosBasicData/losbfeestemplate/feesTemplateItems.vue";
  70. export default {
  71. components:{ feesTemplateItems},
  72. data() {
  73. return {
  74. // 详情传递的数据
  75. detailData:{},
  76. isShow:true,
  77. form: {},
  78. query: {},
  79. loading: true,
  80. page: {
  81. pageSize: 10,
  82. currentPage: 1,
  83. total: 0
  84. },
  85. selectionList: [],
  86. option:{},
  87. optionBack: {
  88. height:'auto',
  89. calcHeight: 30,
  90. tip: false,
  91. searchShow: true,
  92. searchMenuSpan: 6,
  93. border: true,
  94. index: true,
  95. viewBtn: true,
  96. selection: true,
  97. dialogClickModal: false,
  98. column: [
  99. // {
  100. // label: "业务类型 Id",
  101. // prop: "businessTypeId",
  102. // width:120,
  103. // rules: [{
  104. // required: true,
  105. // message: "请输入业务类型 Id",
  106. // trigger: "blur"
  107. // }]
  108. // },
  109. {
  110. label: "业务类型中文名称",
  111. prop: "businessTypeCnName",
  112. width:160,
  113. rules: [{
  114. required: true,
  115. message: "请输入业务类型中文名称",
  116. trigger: "blur"
  117. }]
  118. },
  119. {
  120. label: "业务类型英文名称",
  121. prop: "businessTypeEnName",
  122. width:160,
  123. rules: [{
  124. required: true,
  125. message: "请输入业务类型英文名称",
  126. trigger: "blur"
  127. }]
  128. },
  129. {
  130. label: "模版编号",
  131. prop: "code",
  132. search: true,
  133. rules: [{
  134. required: true,
  135. message: "请输入模版编号",
  136. trigger: "blur"
  137. }]
  138. },
  139. {
  140. label: "模版中文名称",
  141. prop: "cnName",
  142. width:120,
  143. search: true,
  144. searchLabelWidth:120,
  145. rules: [{
  146. required: true,
  147. message: "请输入模版中文名称",
  148. trigger: "blur"
  149. }]
  150. },
  151. {
  152. label: "模版英文名称",
  153. prop: "enName",
  154. width:120,
  155. search: true,
  156. searchLabelWidth:120,
  157. rules: [{
  158. required: true,
  159. message: "请输入模版英文名称",
  160. trigger: "blur"
  161. }]
  162. },
  163. {
  164. label: "收付",
  165. prop: "dc",
  166. type:'select',
  167. dicData:[{
  168. label:'收',
  169. value:'D'
  170. },{
  171. label:'付',
  172. value:'C'
  173. }],
  174. rules: [{
  175. required: true,
  176. message: "请输入收付",
  177. trigger: "blur"
  178. }]
  179. },
  180. {
  181. label: "是否公开共享",
  182. prop: "isShared",
  183. width:100,
  184. type:'select',
  185. dicData:[{
  186. label:'否',
  187. value:0
  188. },{
  189. label:'是',
  190. value:1
  191. }],
  192. rules: [{
  193. required: true,
  194. message: "请输入是否公开共享",
  195. trigger: "blur"
  196. }]
  197. },
  198. {
  199. label: "版本",
  200. prop: "version",
  201. hide:true,
  202. display:false,
  203. },
  204. {
  205. label: "状态",
  206. prop: "status",
  207. type:'select',
  208. dicData:[{
  209. label:'启用',
  210. value:0
  211. },{
  212. label:'停用',
  213. value:1
  214. }],
  215. rules: [{
  216. required: true,
  217. message: "请输入状态",
  218. trigger: "blur"
  219. }]
  220. },
  221. {
  222. label: "是否已删除(0 否 1是)",
  223. prop: "isDeleted",
  224. hide:true,
  225. display:false,
  226. },
  227. {
  228. label: "主键",
  229. prop: "id",
  230. hide:true,
  231. display:false,
  232. },
  233. {
  234. label: "创建人 Id",
  235. prop: "createUser",
  236. hide:true,
  237. display:false,
  238. },
  239. {
  240. label: "创建人",
  241. prop: "createUserName",
  242. display:false,
  243. },
  244. {
  245. label: "创建部门 Id",
  246. prop: "createDept",
  247. hide:true,
  248. display:false,
  249. },
  250. {
  251. label: "创建部门",
  252. prop: "createDeptName",
  253. display:false,
  254. },
  255. {
  256. label: "创建时间",
  257. prop: "createTime",
  258. width: 160,
  259. display:false,
  260. },
  261. {
  262. label: "修改人 Id",
  263. prop: "updateUser",
  264. hide:true,
  265. display:false,
  266. },
  267. {
  268. label: "修改人",
  269. prop: "updateUserName",
  270. display:false,
  271. },
  272. {
  273. label: "修改时间",
  274. prop: "updateTime",
  275. width: 160,
  276. display:false,
  277. },
  278. {
  279. label: "备注",
  280. prop: "remarks",
  281. span:24,
  282. type: 'textarea',
  283. width: "180",
  284. slot: true,
  285. minRows: 3,
  286. },
  287. ]
  288. },
  289. data: []
  290. };
  291. },
  292. computed: {
  293. ...mapGetters(["permission"]),
  294. permissionList() {
  295. return {
  296. addBtn: this.vaildData(this.permission.losbfeestemplate_add, false),
  297. viewBtn: this.vaildData(this.permission.losbfeestemplate_view, false),
  298. delBtn: this.vaildData(this.permission.losbfeestemplate_delete, false),
  299. editBtn: this.vaildData(this.permission.losbfeestemplate_edit, false)
  300. };
  301. },
  302. ids() {
  303. let ids = [];
  304. this.selectionList.forEach(ele => {
  305. ids.push(ele.id);
  306. });
  307. return ids.join(",");
  308. }
  309. },
  310. async created() {
  311. this.option = await this.getColumnData(this.getColumnName(303), this.optionBack);
  312. },
  313. methods: {
  314. // 详情的返回列表
  315. goBack(){
  316. // 初始化数据
  317. // this.detailData = this.$options.data().detailData;
  318. if (JSON.stringify(this.$route.query) != "{}") {
  319. this.$router.$avueRouter.closeTag();
  320. this.$router.push({
  321. path: "/iosBasicData/losbfeestemplate/index"
  322. });
  323. }
  324. this.isShow = true;
  325. this.onLoad(this.page, this.search);
  326. },
  327. // 添加弹窗开启
  328. addbtnfun(){
  329. this.detailData = {
  330. seeDisabled: false,
  331. };
  332. this.isShow = false
  333. },
  334. // 编辑详情打开
  335. rowCellfun(row,index){
  336. this.detailData = {
  337. seeDisabled: true,
  338. id: row.id
  339. };
  340. this.isShow = false
  341. this.$nextTick(()=>{
  342. this.$refs.feesTemplateItems.losbfeestemplateDetailfun(row.id)
  343. })
  344. },
  345. rowSave(row, done, loading) {
  346. losbfeestemplateSubmit(row).then(() => {
  347. this.onLoad(this.page);
  348. this.$message({
  349. type: "success",
  350. message: "操作成功!"
  351. });
  352. done();
  353. }, error => {
  354. loading();
  355. window.console.log(error);
  356. });
  357. },
  358. rowUpdate(row, index, done, loading) {
  359. losbfeestemplateSubmit(row).then(() => {
  360. this.onLoad(this.page);
  361. this.$message({
  362. type: "success",
  363. message: "操作成功!"
  364. });
  365. done();
  366. }, error => {
  367. loading();
  368. console.log(error);
  369. });
  370. },
  371. rowDel(row) {
  372. this.$confirm("确定将选择数据删除?", {
  373. confirmButtonText: "确定",
  374. cancelButtonText: "取消",
  375. type: "warning"
  376. })
  377. .then(() => {
  378. return losbfeestemplateRemove(row.id);
  379. })
  380. .then(() => {
  381. this.onLoad(this.page);
  382. this.$message({
  383. type: "success",
  384. message: "操作成功!"
  385. });
  386. });
  387. },
  388. handleDelete() {
  389. if (this.selectionList.length === 0) {
  390. this.$message.warning("请选择至少一条数据");
  391. return;
  392. }
  393. this.$confirm("确定将选择数据删除?", {
  394. confirmButtonText: "确定",
  395. cancelButtonText: "取消",
  396. type: "warning"
  397. })
  398. .then(() => {
  399. return losbfeestemplateRemove(this.ids);
  400. })
  401. .then(() => {
  402. this.onLoad(this.page);
  403. this.$message({
  404. type: "success",
  405. message: "操作成功!"
  406. });
  407. this.$refs.crud.toggleSelection();
  408. });
  409. },
  410. beforeOpen(done, type) {
  411. if (["edit", "view"].includes(type)) {
  412. losbfeestemplateDetail(this.form.id).then(res => {
  413. this.form = res.data.data;
  414. });
  415. }
  416. done();
  417. },
  418. searchReset() {
  419. this.query = {};
  420. this.onLoad(this.page);
  421. },
  422. searchChange(params, done) {
  423. this.query = params;
  424. this.page.currentPage = 1;
  425. this.onLoad(this.page, params);
  426. done();
  427. },
  428. selectionChange(list) {
  429. this.selectionList = list;
  430. },
  431. selectionClear() {
  432. this.selectionList = [];
  433. this.$refs.crud.toggleSelection();
  434. },
  435. currentChange(currentPage){
  436. this.page.currentPage = currentPage;
  437. },
  438. sizeChange(pageSize){
  439. this.page.pageSize = pageSize;
  440. },
  441. refreshChange() {
  442. this.onLoad(this.page, this.query);
  443. },
  444. onLoad(page, params = {}) {
  445. this.loading = true;
  446. losbfeestemplateList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  447. const data = res.data.data;
  448. this.page.total = data.total;
  449. this.data = data.records;
  450. this.loading = false;
  451. this.selectionClear();
  452. });
  453. },
  454. //自定义列保存
  455. async saveColumnTwo(ref, option, optionBack, code) {
  456. /**
  457. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  458. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  459. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  460. */
  461. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  462. if (inSave) {
  463. this.$message.success("保存成功");
  464. //关闭窗口
  465. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  466. }
  467. },
  468. //自定义列重置
  469. async resetColumnTwo(ref, option, optionBack, code) {
  470. this[option] = this[optionBack];
  471. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  472. if (inSave) {
  473. this.$message.success("重置成功");
  474. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  475. }
  476. },
  477. // 更改表格颜色
  478. headerClassName(tab){
  479. //颜色间隔
  480. let back = ""
  481. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  482. if (tab.columnIndex % 2 === 0) {
  483. back = "back-one"
  484. } else if (tab.columnIndex % 2 === 1) {
  485. back = "back-two"
  486. }
  487. }
  488. return back;
  489. },
  490. }
  491. };
  492. </script>
  493. <style scoped>
  494. ::v-deep#out-table .back-one {
  495. background: #ecf5ff !important;
  496. }
  497. ::v-deep#out-table .back-two {
  498. background: #ecf5ff !important;
  499. }
  500. </style>