index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="form" ref="form" size="small" :inline="true" label-position="left" label-width="70px">
  4. <el-form-item>
  5. <el-input v-model="form.label" placeholder="请输入" clearable />
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="handleCurrentGetList">查询</el-button>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" @click="handleOpenDialog('add', {})">新增</el-button>
  12. </el-form-item>
  13. </el-form>
  14. <tableList
  15. ref="table"
  16. :column="tableConfig"
  17. showOperation
  18. operationWidth="100px"
  19. :checkbox="false"
  20. :getList="handleGetList"
  21. >
  22. <!-- 列表操作页 -->
  23. <template #default="scope">
  24. <!-- 已生效只能看详情 -->
  25. <f-btn type="text" @click="handleOpenDialog('edit',scope.row)">编辑</f-btn>
  26. <f-btn type="delete" @click="handleDelete('del', scope.row)">删除</f-btn>
  27. </template>
  28. </tableList>
  29. <!-- 详情弹窗 -->
  30. <detail-dialog
  31. ref="detailDialog"
  32. :rowData="rowData"
  33. :dialogType="dialogType"
  34. @updateList="handleCurrentGetList"
  35. />
  36. </div>
  37. </template>
  38. <script>
  39. import DetailDialog from './blocks/detailDialog.vue';
  40. import tableList from "@/comComponents/tableList";
  41. import { addBaseApi } from '@/api/base/addBase'
  42. // 下拉框选项
  43. const useStatus = [
  44. { name: '启用', value: '0' },
  45. { name: '禁用', value: '1' },
  46. ];
  47. export default {
  48. components: { DetailDialog, tableList },
  49. data() {
  50. return {
  51. form: {
  52. label: '',
  53. bootCodeStatus:'0'
  54. },
  55. tableConfig: [
  56. { "name": "基础库名" },
  57. { "bandValue": "波段值" },
  58. { "repeatCode": "重发间隔(ms)" },
  59. { "bootCode": "引导码" },
  60. { "bootCodeSend": "引导码发送次数"},
  61. { "synchronizeCode": "同步码" },
  62. { "synchronizeCodeSend": "同步码发送次数"},
  63. { "dateBinary0": "数据二进制0" },
  64. { "dateBinary1": "数据二进制1" },
  65. { "overCode": "结束码" },
  66. { "status": "状态", formatter: row => this.selectDictLabel(useStatus, row.status)},
  67. { "createTime": "创建时间", formatter:row => this.dayjs(row.createTime).format("YYYY-MM-DD HH:mm")}
  68. ],
  69. // 弹窗数据对象
  70. rowData:{},
  71. // 弹窗类型
  72. dialogType:'add',
  73. // 弹窗更新key
  74. dialogKey:0
  75. }
  76. },
  77. methods: {
  78. selectDictLabel(listObj, key) {
  79. return listObj.find(item => item.value == key).name
  80. },
  81. // 查询列表
  82. handleCurrentGetList(){
  83. this.$refs.table.handleQueryList();
  84. },
  85. // 获取列表
  86. async handleGetList(page) {
  87. const res = await addBaseApi.getList(
  88. {
  89. ...page,
  90. name:this.form.label
  91. }
  92. );
  93. if(res.code!= 200 ) return {
  94. current:1,
  95. records:[],
  96. total:0
  97. }
  98. return res.data;
  99. },
  100. // 打开详情、编辑\新增弹窗事件
  101. handleOpenDialog(type, rowData) {
  102. console.log(type, rowData, '当前数据列项!')
  103. this.dialogType = type;
  104. this.rowData = {...rowData};
  105. this.$nextTick(()=>{
  106. this.$refs.detailDialog.show();
  107. })
  108. },
  109. // 编辑状态
  110. handleDelete(type, row) {
  111. this.$modal.confirm('是否确认删除此配置').then(async ()=> {
  112. const res = await addBaseApi.configDelete({ id: row.id });
  113. if(res.code != 200){
  114. this.$modal.msgErrpr(res.msg || "操作失败");
  115. return false;
  116. }
  117. this.handleCurrentGetList();
  118. this.$modal.msgSuccess("操作成功");
  119. })
  120. }
  121. },
  122. mounted() {
  123. this.handleCurrentGetList()
  124. },
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. </style>