index.vue 15 KB

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