index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <!--费用模板-->
  2. <template>
  3. <div>
  4. <el-row v-if="isShow">
  5. <el-col :span="5">
  6. <div class="box">
  7. <el-scrollbar>
  8. <basic-container>
  9. <avue-tree :option="treeOption" :data="feesTypeData" @node-click="nodeClick">
  10. <template slot="addBtn">
  11. <el-tooltip class="item" effect="dark" content="新建分类" placement="top">
  12. <i class="el-icon-setting" style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;"
  13. @click="corpTypeVisible = true"></i>
  14. </el-tooltip>
  15. </template>
  16. </avue-tree>
  17. </basic-container>
  18. </el-scrollbar>
  19. </div>
  20. </el-col>
  21. <el-col :span="19">
  22. <basic-container>
  23. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="search"
  24. :permission="permissionList" id="out-table" :header-cell-class-name="headerClassName"
  25. :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
  26. @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
  27. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  28. @refresh-change="refreshChange" @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 303)"
  29. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 303)" @on-load="onLoad">
  30. <template slot="menuLeft">
  31. <el-button type="primary" size="small" icon="el-icon-plus" @click="addbtnfun()">新增费用模板
  32. </el-button>
  33. <el-button type="danger" size="small" icon="el-icon-delete" plain @click="handleDelete">删 除
  34. </el-button>
  35. <el-button type="warning" size="small" icon="el-icon-printer" @click="excelBox = true">导 入
  36. </el-button>
  37. <el-button type="success" size="small" @click="handleExport" icon="el-icon-printer">导 出</el-button>
  38. <el-button type="info" size="small" icon="el-icon-plus" @click="copyTemplate" :disabled="selectionList.length!=1">复 制</el-button>
  39. </template>
  40. <template slot-scope="scope" slot="menu">
  41. <el-button :type="scope.type" :size="scope.size" icon="el-icon-edit"
  42. @click.stop="rowCellfun(scope.row, scope.index)">编辑
  43. </el-button>
  44. <el-button :type="scope.type" :size="scope.size" icon="el-icon-delete"
  45. @click.stop="rowDel(scope.row, scope.index)">删除
  46. </el-button>
  47. <el-button v-if="scope.row.status == 1" type="text" icon="el-icon-turn-off" style="color: #85e967" size="small"
  48. @click.stop="statusfun(scope.row.id,0)">
  49. 启用
  50. </el-button>
  51. <el-button v-if="scope.row.status == 0" type="text" icon="el-icon-turn-off" style="color: #e83c3a" size="small"
  52. @click.stop="statusfun(scope.row.id,1)">
  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. </el-col>
  64. </el-row>
  65. <fees-templateItems ref="feesTemplateItems" v-if="!isShow" :detailData="detailData"
  66. @goBack="goBack"></fees-templateItems>
  67. <!--类别弹窗-->
  68. <el-dialog title="类别" :visible.sync="corpTypeVisible" append-to-body width="60%" :before-close="corpTypeClose">
  69. <div>
  70. <bbusinesstype></bbusinesstype>
  71. </div>
  72. <span slot="footer" class="dialog-footer">
  73. <el-button @click="corpTypeVisible = false">取 消</el-button>
  74. <el-button type="primary" @click="corpTypeVisible = false">确 定</el-button>
  75. </span>
  76. </el-dialog>
  77. <el-dialog title="导入费用模板" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  78. v-dialog-drag>
  79. <avue-form :option="excelOption" v-model="excelForm" :table-loading="excelLoading" :upload-before="uploadBefore"
  80. :upload-after="onSuccess">
  81. <template slot="excelTemplate">
  82. <el-button type="primary" @click="handleGet">
  83. 点击下载<i class="el-icon-download el-icon--right"></i>
  84. </el-button>
  85. </template>
  86. </avue-form>
  87. <p style="text-align: center;color: #DC0505">
  88. 温馨提示 第一次导入时请先下载模板
  89. </p>
  90. </el-dialog>
  91. </div>
  92. </template>
  93. <script>
  94. import { losbfeestemplateList, losbfeestemplateDetail, losbfeestemplateSubmit, losbfeestemplateRemove } from "@/api/iosBasicData/losbfeestemplate.js";
  95. import { mapGetters } from "vuex";
  96. import feesTemplateItems from "@/views/iosBasicData/losbfeestemplate/feesTemplateItems.vue";
  97. import { bbusinesstypeList } from "@/api/iosBasicData/bbusinesstype";
  98. import bbusinesstype from "@/views/iosBasicData/bbusinesstype/index.vue";
  99. import { getToken } from "@/util/auth";
  100. export default {
  101. components: { feesTemplateItems, bbusinesstype },
  102. data() {
  103. return {
  104. treeOption: {
  105. nodeKey: "id",
  106. // lazy: true,
  107. addBtn: false,
  108. menu: false,
  109. size: "small",
  110. props: {
  111. labelText: "标题",
  112. label: "cnName",
  113. value: "value",
  114. children: "children"
  115. }
  116. },
  117. feesTypeData: [],
  118. corpTypeVisible: false,
  119. // 详情传递的数据
  120. detailData: {},
  121. isShow: true,
  122. form: {},
  123. query: {},
  124. loading: true,
  125. excelBox: false,
  126. search: {},
  127. excelForm: {},
  128. excelLoading: false,
  129. excelOption: {
  130. submitBtn: false,
  131. emptyBtn: false,
  132. column: [
  133. {
  134. label: "模板下载",
  135. prop: "excelTemplate",
  136. formslot: true,
  137. span: 24
  138. },
  139. {
  140. label: "模板上传",
  141. prop: "excelFile",
  142. type: "upload",
  143. drag: true,
  144. loadText: "模板上传中,请稍等",
  145. span: 24,
  146. propsHttp: {
  147. res: "data"
  148. },
  149. tip: "请上传 .xls,.xlsx 标准格式文件",
  150. action: "/api/blade-los/losbfeestemplate/importLosBFeesTemplate"
  151. }
  152. ]
  153. },
  154. page: {
  155. pageSize: 20,
  156. currentPage: 1,
  157. total: 0,
  158. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  159. },
  160. selectionList: [],
  161. option: {
  162. dialogDrag: true,
  163. },
  164. optionBack: {
  165. dialogDrag: true,
  166. height: 'auto',
  167. calcHeight: 30,
  168. tip: false,
  169. searchShow: true,
  170. searchMenuSpan: 24,
  171. border: true,
  172. index: true,
  173. viewBtn: false,
  174. selection: true,
  175. dialogClickModal: false,
  176. menuWidth:220,
  177. column: [
  178. // {
  179. // label: "业务类型 Id",
  180. // prop: "businessTypeId",
  181. // width:120,
  182. // rules: [{
  183. // required: true,
  184. // message: "请输入业务类型 Id",
  185. // trigger: "blur"
  186. // }]
  187. // },
  188. {
  189. label: "编码",
  190. prop: "code",
  191. width: "180",
  192. search: true,
  193. rules: [{
  194. required: true,
  195. message: "请输入编码",
  196. trigger: "blur"
  197. }],
  198. overHidden:true
  199. },
  200. {
  201. label: "中文名称",
  202. prop: "cnName",
  203. width: "180",
  204. search: true,
  205. searchLabelWidth: 120,
  206. rules: [{
  207. required: true,
  208. message: "请输入中文名称",
  209. trigger: "blur"
  210. }],
  211. overHidden:true
  212. },
  213. {
  214. label: "英文名称",
  215. prop: "enName",
  216. width: "180",
  217. search: true,
  218. searchLabelWidth: 120,
  219. rules: [{
  220. required: true,
  221. message: "请输入英文名称",
  222. trigger: "blur"
  223. }],
  224. overHidden:true
  225. },
  226. {
  227. label: "业务类型中文名称",
  228. prop: "businessTypeCnName",
  229. width: 160,
  230. rules: [{
  231. required: true,
  232. message: "请输入业务类型中文名称",
  233. trigger: "blur"
  234. }],
  235. overHidden:true
  236. },
  237. {
  238. label: "业务类型英文名称",
  239. prop: "businessTypeEnName",
  240. width: 160,
  241. rules: [{
  242. required: true,
  243. message: "请输入业务类型英文名称",
  244. trigger: "blur"
  245. }],
  246. overHidden:true
  247. },
  248. {
  249. label: "收付",
  250. prop: "dc",
  251. type: 'select',
  252. dicData: [{
  253. label: '收',
  254. value: 'D'
  255. }, {
  256. label: '付',
  257. value: 'C'
  258. }],
  259. rules: [{
  260. required: true,
  261. message: "请输入收付",
  262. trigger: "blur"
  263. }],
  264. overHidden:true
  265. },
  266. {
  267. label: "是否公开共享",
  268. prop: "isShared",
  269. width: 100,
  270. type: 'select',
  271. dicData: [{
  272. label: '否',
  273. value: 0
  274. }, {
  275. label: '是',
  276. value: 1
  277. }],
  278. rules: [{
  279. required: true,
  280. message: "请输入是否公开共享",
  281. trigger: "blur"
  282. }],
  283. overHidden:true
  284. },
  285. {
  286. label: "版本",
  287. prop: "version",
  288. hide: true,
  289. display: false,
  290. overHidden:true
  291. },
  292. {
  293. label: "备注",
  294. prop: "remarks",
  295. span: 24,
  296. type: 'textarea',
  297. width: "180",
  298. slot: true,
  299. minRows: 3,
  300. overHidden:true
  301. },
  302. {
  303. label: "状态",
  304. prop: "status",
  305. type: 'select',
  306. search: true,
  307. dicData: [{
  308. label: '启用',
  309. value: 0
  310. }, {
  311. label: '停用',
  312. value: 1
  313. }],
  314. rules: [{
  315. required: true,
  316. message: "请输入状态",
  317. trigger: "blur"
  318. }],
  319. overHidden:true
  320. },
  321. {
  322. label: "是否已删除(0 否 1是)",
  323. prop: "isDeleted",
  324. hide: true,
  325. display: false,
  326. overHidden:true
  327. },
  328. {
  329. label: "创建人",
  330. prop: "createUserName",
  331. display: false,
  332. overHidden:true
  333. },
  334. {
  335. label: "创建部门",
  336. prop: "createDeptName",
  337. display: false,
  338. overHidden:true
  339. },
  340. {
  341. label: "创建时间",
  342. prop: "createTime",
  343. width: 160,
  344. display: false,
  345. overHidden:true
  346. },
  347. {
  348. label: "修改人",
  349. prop: "updateUserName",
  350. display: false,
  351. overHidden:true
  352. },
  353. {
  354. label: "修改时间",
  355. prop: "updateTime",
  356. width: 160,
  357. display: false,
  358. overHidden:true
  359. },
  360. ]
  361. },
  362. data: []
  363. };
  364. },
  365. computed: {
  366. ...mapGetters(["permission"]),
  367. permissionList() {
  368. return {
  369. addBtn: this.vaildData(this.permission.losbfeestemplate_add, false),
  370. viewBtn: this.vaildData(this.permission.losbfeestemplate_view, false),
  371. delBtn: this.vaildData(this.permission.losbfeestemplate_delete, false),
  372. editBtn: this.vaildData(this.permission.losbfeestemplate_edit, false)
  373. };
  374. },
  375. ids() {
  376. let ids = [];
  377. this.selectionList.forEach(ele => {
  378. ids.push(ele.id);
  379. });
  380. return ids.join(",");
  381. }
  382. },
  383. async created() {
  384. this.option = await this.getColumnData(this.getColumnName(303), this.optionBack);
  385. this.bbusinesstypeListfun()
  386. },
  387. methods: {
  388. // 禁用启用按钮
  389. statusfun(id,status){
  390. this.$confirm("确定将选择数据更改状态?", {
  391. confirmButtonText: "确定",
  392. cancelButtonText: "取消",
  393. type: "warning"
  394. }).then(()=>{
  395. losbfeestemplateDetail(id).then(res=>{
  396. let obj = res.data.data;
  397. obj.status = status
  398. losbfeestemplateSubmit(obj).then(()=>{
  399. this.onLoad(this.page);
  400. this.$message({
  401. type: "success",
  402. message: "操作成功!"
  403. });
  404. })
  405. })
  406. })
  407. },
  408. // 导出
  409. handleExport() {
  410. var condition = ''
  411. for (const key in this.search) {
  412. var value = this.search[key]
  413. if (value) {
  414. condition += `&${key}=${this.search[key]}`
  415. }
  416. }
  417. this.$confirm('是否导出费用模板?', '提示', {
  418. confirmButtonText: '确定',
  419. cancelButtonText: '取消',
  420. type: 'warning'
  421. }).then(() => {
  422. window.open(
  423. `/api/blade-los/losbfeestemplate/exportLosBFeesTemplate?${this.website.tokenHeader
  424. }=${getToken()}${condition}`
  425. );
  426. }).catch(() => {
  427. this.$message({
  428. type: 'info',
  429. message: '已取消' //
  430. });
  431. })
  432. },
  433. uploadBefore(file, done, loading) {
  434. done();
  435. loading = true;
  436. },
  437. // 上传成功
  438. onSuccess(res, done, loading, column) {
  439. this.excelBox = false;
  440. this.$message.success("导入成功!");
  441. loading = false;
  442. this.onLoad(this.page);
  443. done();
  444. },
  445. // 下载模板
  446. handleGet() {
  447. window.open(
  448. `/api/blade-los/losbfeestemplate/exportLosBFeesTemplate/template?${this.website.tokenHeader
  449. }=${getToken()}`
  450. );
  451. },
  452. // 获取左侧业务类别数据
  453. bbusinesstypeListfun() {
  454. bbusinesstypeList(1,100,{enableFee:'1'}).then(res => {
  455. this.feesTypeData = res.data.data.records
  456. })
  457. },
  458. // 详情的返回列表
  459. goBack() {
  460. // 初始化数据
  461. // this.detailData = this.$options.data().detailData;
  462. if (JSON.stringify(this.$route.query) != "{}") {
  463. this.$router.$avueRouter.closeTag();
  464. this.$router.push({
  465. path: "/iosBasicData/losbfeestemplate/index"
  466. });
  467. }
  468. this.isShow = true;
  469. console.log(this.page, this.search)
  470. this.onLoad(this.page, this.search);
  471. },
  472. // 左侧筛选
  473. nodeClick(data) {
  474. this.search.businessTypeId = data.id
  475. this.detailData.businessTypeId = data.id
  476. this.detailData.businessTypeCnName = data.cnName
  477. this.detailData.businessTypeEnName = data.enName
  478. this.detailData.businessTypeCode = data.code
  479. this.searchChange(this.search)
  480. // this.onLoad(this.page, this.search);
  481. },
  482. // 添加弹窗开启
  483. addbtnfun() {
  484. if (!this.detailData.businessTypeId) {
  485. this.$message({
  486. type: "warning",
  487. message: "请先选择业务类型!"
  488. });
  489. return
  490. }
  491. this.detailData.seeDisabled = false
  492. this.isShow = false
  493. this.$nextTick(() => {
  494. this.$refs.feesTemplateItems.form.businessTypeId = this.detailData.businessTypeId
  495. this.$refs.feesTemplateItems.form.businessTypeCnName = this.detailData.businessTypeCnName
  496. this.$refs.feesTemplateItems.form.businessTypeEnName = this.detailData.businessTypeEnName
  497. this.$refs.feesTemplateItems.form.businessTypeCode = this.detailData.businessTypeCode
  498. })
  499. },
  500. copyTemplate(){
  501. let copyId=null
  502. this.selectionList.forEach(e=>{
  503. copyId=e.id
  504. })
  505. this.isShow=false
  506. this.$nextTick(() => {
  507. this.$refs.feesTemplateItems.getCopyTemplate(copyId)
  508. })
  509. },
  510. // 编辑详情打开
  511. rowCellfun(row, index) {
  512. this.detailData = {
  513. seeDisabled: true,
  514. id: row.id
  515. };
  516. this.isShow = false
  517. this.$nextTick(() => {
  518. this.$refs.feesTemplateItems.losbfeestemplateDetailfun(row.id)
  519. })
  520. },
  521. rowSave(row, done, loading) {
  522. losbfeestemplateSubmit(row).then(() => {
  523. this.onLoad(this.page);
  524. this.$message({
  525. type: "success",
  526. message: "操作成功!"
  527. });
  528. done();
  529. }, error => {
  530. loading();
  531. window.console.log(error);
  532. });
  533. },
  534. rowUpdate(row, index, done, loading) {
  535. losbfeestemplateSubmit(row).then(() => {
  536. this.onLoad(this.page);
  537. this.$message({
  538. type: "success",
  539. message: "操作成功!"
  540. });
  541. done();
  542. }, error => {
  543. loading();
  544. console.log(error);
  545. });
  546. },
  547. rowDel(row) {
  548. if (row.status === 1) {
  549. this.$confirm("确定将选择数据删除?", {
  550. confirmButtonText: "确定",
  551. cancelButtonText: "取消",
  552. type: "warning"
  553. })
  554. .then(() => {
  555. return losbfeestemplateRemove(row.id);
  556. })
  557. .then(() => {
  558. this.onLoad(this.page);
  559. this.$message({
  560. type: "success",
  561. message: "操作成功!"
  562. });
  563. });
  564. } else {
  565. this.$message({
  566. message: '非禁用状态无法删除',
  567. type: 'warning'
  568. });
  569. }
  570. },
  571. handleDelete() {
  572. if (this.selectionList.length === 0) {
  573. this.$message.warning("请选择至少一条数据");
  574. return;
  575. }
  576. for (const selection of this.selectionList) {
  577. if (selection.status == 0) {
  578. this.$message.warning("选中的数据中有启用数据,启用数据不可删除!");
  579. return;
  580. }
  581. }
  582. this.$confirm("确定将选择数据删除?", {
  583. confirmButtonText: "确定",
  584. cancelButtonText: "取消",
  585. type: "warning"
  586. })
  587. .then(() => {
  588. return losbfeestemplateRemove(this.ids);
  589. })
  590. .then(() => {
  591. this.onLoad(this.page);
  592. this.$message({
  593. type: "success",
  594. message: "操作成功!"
  595. });
  596. this.$refs.crud.toggleSelection();
  597. });
  598. },
  599. beforeOpen(done, type) {
  600. if (["edit", "view"].includes(type)) {
  601. losbfeestemplateDetail(this.form.id).then(res => {
  602. this.form = res.data.data;
  603. });
  604. }
  605. done();
  606. },
  607. searchReset() {
  608. this.query = {};
  609. this.onLoad(this.page);
  610. },
  611. searchChange(params, done) {
  612. this.query = params;
  613. this.page.currentPage = 1;
  614. this.onLoad(this.page, params);
  615. done();
  616. },
  617. selectionChange(list) {
  618. this.selectionList = list;
  619. },
  620. selectionClear() {
  621. this.selectionList = [];
  622. this.$refs.crud.toggleSelection();
  623. },
  624. currentChange(currentPage) {
  625. this.page.currentPage = currentPage;
  626. },
  627. sizeChange(pageSize) {
  628. this.page.pageSize = pageSize;
  629. },
  630. refreshChange() {
  631. this.onLoad(this.page, this.query);
  632. },
  633. onLoad(page, params = {}) {
  634. this.loading = true;
  635. losbfeestemplateList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  636. const data = res.data.data;
  637. this.page.total = data.total;
  638. this.data = data.records;
  639. this.loading = false;
  640. this.selectionClear();
  641. });
  642. },
  643. // 类别弹窗关闭
  644. corpTypeClose(done) {
  645. done();
  646. // this.$confirm('确认关闭?')
  647. // .then(_ => {
  648. // done();
  649. // })
  650. // .catch(_ => { });
  651. },
  652. //自定义列保存
  653. async saveColumnTwo(ref, option, optionBack, code) {
  654. /**
  655. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  656. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  657. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  658. */
  659. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  660. if (inSave) {
  661. this.$message.success("保存成功");
  662. //关闭窗口
  663. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  664. }
  665. },
  666. //自定义列重置
  667. async resetColumnTwo(ref, option, optionBack, code) {
  668. this[option] = this[optionBack];
  669. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  670. if (inSave) {
  671. this.$message.success("重置成功");
  672. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  673. }
  674. },
  675. // 更改表格颜色
  676. headerClassName(tab) {
  677. //颜色间隔
  678. let back = ""
  679. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  680. if (tab.columnIndex % 2 === 0) {
  681. back = "back-one"
  682. } else if (tab.columnIndex % 2 === 1) {
  683. back = "back-two"
  684. }
  685. }
  686. return back;
  687. },
  688. }
  689. };
  690. </script>
  691. <style scoped>
  692. ::v-deep#out-table .back-one {
  693. background: #ecf5ff !important;
  694. }
  695. ::v-deep#out-table .back-two {
  696. background: #ecf5ff !important;
  697. }
  698. ::v-deep .el-input-group__append {
  699. padding: 0 0px !important;
  700. }
  701. ::v-deep .el-dialog__body {
  702. padding: 0 20px 10px 20px !important;
  703. }
  704. </style>