index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <el-col :span="24">
  5. <div class="cell">
  6. <div class="cell-title">
  7. <div class="title">费率管理</div>
  8. <div class="title-right">
  9. <!-- <el-button type="primary" @click="handler_download_excel">导出表单</el-button> -->
  10. <el-button type="warning" @click="add_feilv">新增费率</el-button>
  11. </div>
  12. </div>
  13. <div class="cell-body">
  14. <el-table :data="tableData" height="610" style="width: 100%" :cell-style="cell_style"
  15. v-loading="loading" :header-cell-style="header_cell_style">
  16. <!-- <el-table-column label="id" align="center" width="100">
  17. <template slot-scope="scope">
  18. <span>{{scope.row.id}}</span>
  19. </template>
  20. </el-table-column> -->
  21. <el-table-column label="型号(匹)" align="center" width="180">
  22. <template slot-scope="scope">
  23. <span>{{ scope.row.air_config }}</span>
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="费率(元)" align="center" width="180">
  27. <template slot-scope="scope">
  28. <span>{{ scope.row.rate }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="操作" align="left">
  32. <template slot-scope="scope">
  33. <el-button v-if="currentUserLevel == 2" size="mini" class="btn-table"
  34. @click="modifyFeilv_dialog(scope.$index, scope.row)">修改</el-button>
  35. <el-button size="mini" class="btn-table" type="danger"
  36. @click="delete_feilv(scope.$index, scope.row)">
  37. 删除</el-button>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. </div>
  42. </div>
  43. </el-col>
  44. </el-row>
  45. <!-- 新增费率对话框 -->
  46. <el-dialog title="新增费率" custom-class="add-user-dialog" :visible.sync="dialogAddFeilvVisible"
  47. :close-on-click-modal="false" :close-on-press-escape="false" @close="dialog_close('addFeilvForm')">
  48. <el-form :model="addForm" ref="addFeilvForm" :rules="addFormRules">
  49. <el-form-item label="型号:" :label-width="formLabelWidth" :required="true" prop="air_config">
  50. <el-input v-model="addForm.air_config" autocomplete="off" maxlength="3" ref="airconfig_focus">
  51. <template slot="append">匹</template>
  52. </el-input>
  53. </el-form-item>
  54. <el-form-item label="费率:" :label-width="formLabelWidth" :required="true" prop="rate">
  55. <el-input v-model="addForm.rate" autocomplete="off" maxlength="4">
  56. <template slot="append">元</template>
  57. </el-input>
  58. </el-form-item>
  59. </el-form>
  60. <div slot="footer" class="dialog-footer">
  61. <el-button @click="dialogAddFeilvVisible = false">取 消</el-button>
  62. <el-button type="primary" @click="handler_add_feilv">新 增</el-button>
  63. </div>
  64. </el-dialog>
  65. <!-- 修改费率对话框 -->
  66. <el-dialog title="修改费率" custom-class="modify-feilv-dialog" :visible.sync="dialogModifyFeilvVisible"
  67. :close-on-click-modal="false" :close-on-press-escape="false" @close="dialog_close('modifyForm')">
  68. <el-form :model="form" ref="modifyForm" :rules="modifyRules">
  69. <el-form-item label="型号:" :label-width="formLabelWidth" :required="true" prop="air_config_modify">
  70. <el-input v-model="form.air_config_modify" autocomplete="off" maxlength="3" ref="modifyFeilv_focus">
  71. <template slot="append">匹</template>
  72. </el-input>
  73. </el-form-item>
  74. <el-form-item label="费率:" :label-width="formLabelWidth" :required="true" prop="rate_modify">
  75. <el-input v-model="form.rate_modify" autocomplete="off" maxlength="4">
  76. <template slot="append">元</template>
  77. </el-input>
  78. </el-form-item>
  79. </el-form>
  80. <div slot="footer" class="dialog-footer">
  81. <el-button @click="dialogModifyFeilvVisible = false">取 消</el-button>
  82. <el-button type="primary" @click="handler_modify_feilv">确 定</el-button>
  83. </div>
  84. </el-dialog>
  85. <!-- 删除费率对话框 -->
  86. <el-dialog custom-class="el-dialog-delete-feilv" :visible.sync="dialog_delete_feilv"
  87. :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
  88. <div slot="" class="del-account-body">
  89. <img src="../../icons/serveAC/del_warning.png" alt="">
  90. <div class="del-account-body-txt">是否确定将该【{{delForm.air_config}}】从列表中移除?</div>
  91. </div>
  92. <div slot="footer" class="dialog-footer">
  93. <el-button @click="dialog_delete_feilv = false"> 否 </el-button>
  94. <el-button type="primary" @click="delete_fielv_dialog"> 是 </el-button>
  95. </div>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. import {
  101. mapGetters
  102. } from 'vuex';
  103. import {
  104. getList,
  105. addFeilv,
  106. modifyFeilv,
  107. delFeilv
  108. } from '@/api/feilvSet';
  109. export default {
  110. data() {
  111. var checkAirConfig = (rule, value, callback) => {
  112. if (!value) {
  113. return callback(new Error('请输入型号,最多3位整数或小数!'));
  114. }
  115. setTimeout(() => {
  116. var reg = /^[1-9]{1}$|^[1-9][\.][0-9]{1}$/
  117. if (!reg.test(value)) {
  118. callback(new Error('必须正整数或小数,如:1.5 或 5'));
  119. } else {
  120. callback();
  121. }
  122. }, 100);
  123. }
  124. var checkFeilv = (rule, value, callback) => {
  125. if (!value) {
  126. return callback(new Error('请输入费率,最多4位整数或小数!'));
  127. }
  128. setTimeout(() => {
  129. var reg = /^[1-9]{1,2}$|^[1-9][\.][0-9]{1,2}$/
  130. if (!reg.test(value)) {
  131. callback(new Error('必须正整数或小数'));
  132. } else {
  133. callback();
  134. }
  135. }, 100);
  136. }
  137. return {
  138. // 当前费率的权限
  139. currentUserLevel: this.$store.state.user.level,
  140. // 弹出对话框数据
  141. dialogModifyFeilvVisible: false,
  142. form: {
  143. id: '',
  144. air_config_modify: '',
  145. rate_modify: ''
  146. },
  147. modifyRules: {
  148. air_config_modify: [{
  149. validator: checkAirConfig
  150. }],
  151. rate_modify: [{
  152. validator: checkFeilv
  153. }]
  154. },
  155. // 添加费率对话框数据
  156. dialogAddFeilvVisible: false,
  157. addForm: {
  158. air_config: '',
  159. rate: ''
  160. },
  161. addFormRules: {
  162. air_config: [{
  163. validator: checkAirConfig
  164. }],
  165. rate: [{
  166. validator: checkFeilv
  167. }]
  168. },
  169. delForm: {
  170. id: '',
  171. air_config: '',
  172. rate: ''
  173. },
  174. dialog_delete_feilv: false,
  175. tableData: [],
  176. formLabelWidth: '120px',
  177. // 表格单元格样式
  178. cell_style: {
  179. color: '#1A202B',
  180. 'font-size': '16px',
  181. 'font-family': 'Microsoft YaHei-3970(82674968)'
  182. },
  183. // 表格头部样式
  184. header_cell_style: {
  185. background: '#E6ECFE',
  186. color: '#1A202B',
  187. 'font-size': '18px',
  188. 'font-family': 'Microsoft YaHei-3970(82674968)'
  189. },
  190. loading: true
  191. }
  192. },
  193. created() {
  194. // 获取费率列表数据
  195. this.get_list()
  196. },
  197. methods: {
  198. delete_feilv(index, row) {
  199. // console.log(index, row);
  200. this.delForm.id = row.id
  201. this.delForm.air_config = row.air_config
  202. this.delForm.rate = row.rate
  203. this.dialog_delete_feilv = true
  204. },
  205. delete_fielv_dialog() {
  206. let params = {
  207. id: this.delForm.id,
  208. // air_config: this.delForm.air_config,
  209. // rate: this.delForm.rate
  210. }
  211. delFeilv(params).then((res) => {
  212. // console.log(res);
  213. if (typeof res.code == 'undefined' || res.code == '') {
  214. this.$message.error('返回数据格式问题,code未获取到!')
  215. return
  216. }
  217. if (res.code == 200) {
  218. this.dialog_delete_feilv = false
  219. this.$message.success('删除费率成功!')
  220. this.get_list('list')
  221. } else {
  222. this.$message.error(res.message)
  223. }
  224. }).catch((err) => {
  225. // console.log(err);
  226. this.$message.error(err.message)
  227. })
  228. },
  229. /**
  230. * 修改费率
  231. */
  232. handler_modify_feilv() {
  233. this.$refs["modifyForm"].validate(validate => {
  234. if (validate) {
  235. let params = {
  236. id: this.form.id,
  237. air_config: this.form.air_config_modify + '匹',
  238. rate: this.form.rate_modify
  239. }
  240. // console.log(params);
  241. // 开始发送请求,获取配置数据
  242. modifyFeilv(params).then((res) => {
  243. // console.log(res);
  244. if (typeof res.code == 'undefined' || res.code == '') {
  245. this.$message.error('返回数据格式问题,code未获取到!')
  246. return
  247. }
  248. if (res.code == 200) {
  249. this.dialogModifyFeilvVisible = false
  250. this.$message.success('修改费率成功!')
  251. this.get_list('list')
  252. } else {
  253. this.$message.error(res.message)
  254. }
  255. }).catch((err) => {
  256. // console.log(err);
  257. this.$message.error(err.message)
  258. })
  259. } else {
  260. this.$message.error('验证不通过')
  261. return false
  262. }
  263. })
  264. },
  265. /**
  266. * 打开新增费率对话框
  267. */
  268. add_feilv() {
  269. this.dialogAddFeilvVisible = true
  270. setTimeout(() => {
  271. this.$nextTick(() => {
  272. this.$refs.airconfig_focus.focus()
  273. })
  274. }, 100)
  275. },
  276. /**
  277. * 新增费率
  278. */
  279. handler_add_feilv() {
  280. this.$refs["addFeilvForm"].validate(validate => {
  281. // console.log(typeof validate);
  282. // console.log(validate);
  283. if (validate) {
  284. let params = {
  285. air_config: this.addForm.air_config + '匹',
  286. rate: this.addForm.rate
  287. }
  288. // 开始发送请求,获取配置数据
  289. addFeilv(params).then((res) => {
  290. // console.log(res);
  291. if (typeof res.code == 'undefined' || res.code == '') {
  292. this.$message.error('返回数据格式问题,code未获取到!')
  293. return
  294. }
  295. if (res.code == 200) {
  296. this.dialogAddFeilvVisible = false
  297. this.$message.success('新增费率成功!')
  298. this.get_list('list')
  299. } else {
  300. this.$message.error(res.message)
  301. }
  302. }).catch((err) => {
  303. // console.log(err);
  304. this.$message.error(err.message)
  305. })
  306. } else {
  307. this.$message.error('验证不通过')
  308. return false
  309. }
  310. })
  311. },
  312. /**
  313. * 获取费率列表数据
  314. */
  315. get_list() {
  316. this.loading = true
  317. // 开始发送请求,获取配置数据
  318. getList().then((res) => {
  319. // console.log(res.data);
  320. if (res.code == 200) {
  321. let resdata = res.data;
  322. this.tableData = []
  323. for (var i = 0; i < resdata.length; i++) {
  324. this.tableData.push(resdata[i])
  325. }
  326. } else {
  327. this.tableData = []
  328. this.$message.warning('没有符合条件的数据!')
  329. }
  330. }).catch((err) => {
  331. // console.log(err);
  332. this.$message.error(err.message)
  333. });
  334. // loading结束
  335. this.loading = false
  336. },
  337. /**
  338. * 修改费率对话框初始化
  339. * @param {Object} index
  340. * @param {Object} row
  341. */
  342. modifyFeilv_dialog(index, row) {
  343. // console.log(index, row);
  344. this.dialogModifyFeilvVisible = true
  345. this.form.id = row.id
  346. this.form.air_config_modify = row.air_config.substr(0, row.air_config.length - 1)
  347. this.form.rate_modify = row.rate
  348. // 使金额输入框input_amount获得焦点
  349. setTimeout(() => {
  350. this.$nextTick(() => {
  351. this.$refs.modifyFeilv_focus.focus()
  352. })
  353. }, 100)
  354. },
  355. /**
  356. * 对话框关闭时清理数据
  357. */
  358. dialog_close(param) {
  359. if (param == 'addFeilvForm') {
  360. this.addForm.air_config = ''
  361. this.addForm.rate = ''
  362. } else if (param == 'modifyForm') {
  363. this.form.id = ''
  364. this.form.air_config_modify = ''
  365. this.form.rate_modify = ''
  366. }
  367. }
  368. }
  369. }
  370. </script>
  371. <style lang="scss" scoped>
  372. .app-container {
  373. background-color: #EFF2F7;
  374. padding: 10px;
  375. .el-row {
  376. .el-col {
  377. padding: 10px;
  378. .cell {
  379. padding: 30px;
  380. border-radius: 10px;
  381. background-color: #FFFFFF;
  382. // box-shadow: 5px 5px 15px #979797;
  383. box-shadow: 0px 3px 21px 0px rgba(60, 108, 254, 0.16);
  384. .cell-title {
  385. display: flex;
  386. justify-content: space-between;
  387. align-items: center;
  388. margin-bottom: 30px;
  389. padding-bottom: 30px;
  390. border-bottom: 1px solid #CCCCCC;
  391. .title {
  392. font-size: 22px;
  393. font-family: Microsoft YaHei-3970(82674968);
  394. font-weight: bold;
  395. color: #1A202B;
  396. }
  397. .title-right {
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. .el-button {
  402. width: 110px;
  403. height: 46px;
  404. background: #2B4CFE;
  405. font-size: 18px;
  406. color: #FFFFFF;
  407. font-family: Microsoft YaHei-3970(82674968);
  408. border-radius: 5px;
  409. }
  410. .el-button--warning {
  411. background: #F88A64;
  412. }
  413. }
  414. }
  415. .cell-body {
  416. .el-button--warning {
  417. background: #F88A64;
  418. }
  419. .btn-table {
  420. border-radius: 15px !important;
  421. border-color: #5488FE;
  422. background: #FFFFFF;
  423. color: #5488FE;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. ::v-deep .el-dialog {
  430. margin: 0 !important;
  431. width: 400px;
  432. height: 500px;
  433. background: #FFFFFF;
  434. box-shadow: 0px 0px 13px 0px rgba(0, 0, 0, 0.29);
  435. border-radius: 10px;
  436. position: absolute;
  437. top: 50%;
  438. left: 50%;
  439. transform: translate(-50%, -50%);
  440. .el-dialog__header {
  441. display: flex;
  442. align-items: center;
  443. width: 100%;
  444. height: 58px;
  445. padding: 30px;
  446. background: #E6EBFE;
  447. border-radius: 10px 10px 0px 0px;
  448. font-weight: bold;
  449. }
  450. .el-dialog__body {
  451. padding-bottom: 0;
  452. .el-form-item__label,
  453. .el-form-item__content {
  454. font-size: 16px;
  455. font-family: Microsoft YaHei-3970(82674968);
  456. color: #53575A;
  457. }
  458. // .el-input__inner {
  459. // }
  460. }
  461. // 删除对话框的样式
  462. .del-account-body {
  463. display: flex;
  464. flex-direction: column;
  465. justify-content: center;
  466. align-items: center;
  467. height: 180px;
  468. img {
  469. width: 72px;
  470. }
  471. .del-account-body-txt {
  472. height: 58px;
  473. line-height: 58px;
  474. font-size: 18px;
  475. font-family: Microsoft YaHei-3970(82674968);
  476. color: #333333;
  477. }
  478. }
  479. .el-dialog__footer {
  480. padding-bottom: 0 !important;
  481. text-align: center;
  482. .el-button.el-button--default {
  483. width: 75px;
  484. height: 40px;
  485. border: 1px solid #2B4CFE;
  486. border-radius: 6px;
  487. font-size: 16px;
  488. font-family: Microsoft YaHei-3970(82674968);
  489. color: #2B4CFE;
  490. }
  491. .el-button.el-button--primary {
  492. width: 75px;
  493. height: 40px;
  494. background: #2B4CFE;
  495. border-radius: 6px;
  496. font-size: 16px;
  497. font-family: Microsoft YaHei-3970(82674968);
  498. color: #FFFFFF;
  499. margin-left: 60px;
  500. }
  501. }
  502. }
  503. }
  504. </style>
  505. <style>
  506. .add-user-dialog {
  507. height: 300px !important;
  508. }
  509. .modify-feilv-dialog {
  510. height: 300px !important;
  511. }
  512. .el-dialog-delete-feilv {
  513. height: 300px !important;
  514. width: 460px !important;
  515. }
  516. .el-dialog-delete-feilv .el-dialog__header {
  517. display: none !important;
  518. }
  519. </style>