wangting
2024-09-27 b3fb72072f550cb6dcbdbc2e65bce5d7b0a8e3b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<template>
  <div>
    <el-tabs v-model="areaType" type="card" @tab-click="handleClick">
      <el-tab-pane v-if="uiDefineData.plIsShowNavigator" label="导航区" name="1"></el-tab-pane>
      <el-tab-pane v-if="uiDefineData.plIsShowForm" label="控制区" name="2"></el-tab-pane>
      <el-tab-pane v-if="uiDefineData.plIsShowTab" label="操作区" name="3"></el-tab-pane>
    </el-tabs>
    <avue-crud
      ref="crud"
      :data="data"
      :option="option"
      :table-loading="tableLoading"
      @selection-change="selectChangeHandler"
      @row-click="rowClickHandler">
      <template slot="menuLeft">
        <el-button icon="el-icon-plus" size="small" type="primary" @click="addHandler">创建</el-button>
        <!--<el-button icon="el-icon-edit" plain size="small" type="primary" @click="editHandler">修改</el-button>
        <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delHandler">删除</el-button>-->
      </template>
      <template slot="menu" slot-scope="scope">
        <el-button icon="el-icon-edit" size="small" type="text" @click="rowEditBtnClick(scope.row)">编辑
        </el-button>
        <el-button icon="el-icon-delete" size="small" type="text" @click="rowDeleteHandler(scope.row)">删除
        </el-button>
      </template>
      <template slot="plIsOpen" slot-scope="{row}">
        <el-tag v-if="row.plIsOpen === 1" type="success">启用</el-tag>
        <el-tag v-else type="danger">未启用</el-tag>
      </template>
    </avue-crud>
    <bottom-table :sourceData="selectList[0]" :height="'280px'" style="margin-top: 15px;"></bottom-table>
    <!-- 创建编辑自定义对话框    -->
    <el-dialog
      v-dialogDrag
      v-loading="dialogLoading"
      :title="dialogType === 'add' ? ' 创建 页签' : '编辑 页签'"
      :visible.sync="dialogVisible"
      append-to-body="true"
      class="avue-dialog"
      :close-on-click-modal="false"
      width="800px"
      @close="dialogClose"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="small">
        <el-row>
          <el-col :span="12">
            <el-form-item label="页面编码:" prop="plCode">
              <el-input v-model="form.plCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="名称:" prop="plName">
              <el-input v-model="form.plName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="序号:" prop="plSeq">
              <el-input v-model="form.plSeq"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否启用" prop="plIsOpen">
              <el-switch v-model="form.plIsOpen" :active-value="1"  :inactive-value="0"   active-color="#13ce66"  inactive-color="#ff4949"></el-switch>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="显示表达式:" prop="plOpenExpression">
          <el-input type="textarea" :rows="3" v-model="form.plOpenExpression"></el-input>
        </el-form-item>
        <el-form-item label="国际化标准:" prop="plLabel">
          <el-input type="textarea" :rows="1" v-model="form.plLabel"></el-input>
        </el-form-item>
        <el-form-item label="描述:" prop="plDesc">
          <el-input type="textarea" :rows="1" v-model="form.plDesc"></el-input>
        </el-form-item>
        <el-form-item label="UI解析类:" prop="plUIParser">
          <el-input type="textarea" :rows="2" v-model="form.plUIParser"></el-input>
        </el-form-item>
        <div class="tip">
          <div style="color: #D40000">示例:java_cs:xxx;java_bs:xxx;net_cs:xxx;net_bs:xxx;mobile_cs:xxx;mobile_bs:xxx;</div>
          <div>1、用英文半角分号;分隔各组值。</div>
          <div>2、每组用英文半角冒号:分隔单一拓展属性名称及属性值。</div>
          <div>3、其中的xxx是各种解析类的完整类型名称(完全限定名)。</div>
          <div>4、输入时,不要敲回车换行。</div>
        </div>
        <el-form-item label="拓展属性:" prop="plExtAttr">
          <el-input type="textarea" :rows="2" v-model="form.plExtAttr"></el-input>
        </el-form-item>
        <div class="tip">
          <div style="color: #D40000">示例:ext1:xx;ext2:xx;ext3:xxx;ext4:xxx;extn:xxx</div>
          <div>1、用英文半角分号;分隔各组值。</div>
          <div>2、每组用英文半角冒号:分隔单一拓展属性名称及属性值。</div>
          <div>3、可以定义任意组,但总字符长度不得超过4000。</div>
          <div>4、输入时,不要敲回车换行。</div>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
            <el-button @click="dialogClose">取 消</el-button>
            <el-button type="primary" @click="saveHandler">确 定</el-button>
          </span>
    </el-dialog>
  </div>
</template>
 
<script>
import basicOption from "@/util/basic-option";
import {
  getTabByContextIdAndType,
  addTabData,
  updateTabData,
  deleteTabData,
} from "@/api/UI/uiDefine";
import func from "@/util/func";
import bottomTable from "./bottomTable/index";
 
export default {
name: "plShow",
  props: {
    uiDefineData: {
      type: Object,
      default: {}
    },
  },
  components:{bottomTable},
  data() {
    return {
      uiDefineOid:'',
      areaType: '',
      tableLoading: false,
      selectList: [],
      option: {
        ...basicOption,
        height:'300px',
        addBtn: false,
        editBtn: false,
        delBtn: false,
        index:false,
        menuWidth:160,
        align:'left',
        column: [{
          label: '序号',
          prop: 'plSeq',
          width:50
        }, {
          label: '编码',
          prop: 'plCode',
          width:180
        }, {
          label: '名称',
          prop: 'plName',
          width:200
        }, {
          label: '是否启用',
          prop: 'plIsOpen',
          align:'center',
          width: 90
        }, {
          label: '显示表达式',
          prop: 'plOpenExpression',
          overHidden:true,
          width:300
        }, {
          label: 'UI解析类',
          prop: 'plUIParser'
        }, {
          label: '拓展属性',
          prop: 'plExtAttr'
        }, {
          label: '描述',
          prop: 'plDesc'
        }]
      },
      data: [],
      dialogLoading: false,
      dialogVisible: false,
      dialogType: '',
      form: {
        plSeq: '',
        plCode: '',
        plName: '',
        plIsOpen:0,
        plOpenExpression:'',
        plLabel:'',
        plUIParser:'',
        plExtAttr:'',
        plDesc:''
      },
      rules: {
        plName: [{
          required: true,
          message: '请输入名称',
          trigger: 'blur'
        }],
        plCode: [{
          required: true,
          message: '请输入编码',
          trigger: 'blur'
        }],
        plSeq: [{
          required: true,
          message: '请输入序号',
          trigger: 'blur'
        }]
      },
    }
  },
  watch: {
    uiDefineData:{
      handler(val) {
        if(val && val.plOId) {
          if (val.plIsShowNavigator) {
            this.areaType = '1';
          }else if(val.plIsShowForm){
            this.areaType = '2'
          }else{
            this.areaType = '3'
          }
          this.getTableList()
        }
      },
      immediate: true,
      deep:true
    }
  },
  created() {
    this.uiDefineOid=this.$route.params.uiDefineOid;
  },
  methods: {
    handleClick(tab, event) {
      this.getTableList()
    },
    getTableList(){
      const params = {
        contextId:this.uiDefineData.plOId,
        areaType:this.areaType
      }
      getTabByContextIdAndType( params).then(res => {
        this.data = res.data.data;
        this.selectList=[];
        this.$refs.crud.clearSelection();
        this.tableLoading = false;
      })
    },
    selectChangeHandler(row) {
      this.selectList = row;
    },
    // 行点击
    rowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectList = [];
        }
      );
    },
    //创建
    addHandler(){
      this.form={
        plSeq: '',
        plCode: '',
        plName: '',
        plIsOpen:0,
        plOpenExpression:'',
        plLabel:'',
        plUIParser:'',
        plExtAttr:'',
        plDesc:''
      };
      this.dialogType = 'add';
      this.dialogVisible = true;
    },
    editHandler(){
      if(this.selectList.length!=0){
        this.rowEditBtnClick(this.selectList[0]);
      }else {
        this.$message.error('请选择一条数据进行编辑');
      }
    },
    delHandler(){
      if (this.selectList.length <= 0) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      const params = {
        oids: this.selectList.map(item => item.plOId).join(',')
      }
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteTabData(params).then(res => {
          if (res.data.code === 200) {
            this.$message.success('删除成功');
            this.getTableList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 编辑按钮
    rowEditBtnClick(row) {
      this.form=row;
      this.dialogType = 'edit';
      this.dialogVisible = true;
    },
    // 删除按钮
    rowDeleteHandler(row) {
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteTabData({oids: row.plOId}).then(res => {
          if (res.data.code === 200) {
            this.$message.success('删除成功');
            this.getTableList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 关闭对话框
    dialogClose() {
      this.dialogVisible = false;
      this.$refs.form.clearValidate();
      this.form = {
        plName: '',
        plCode: '',
        plDesc:'',
        plIsShow: [],
      }
    },
    // 保存页签
    saveHandler() {
      this.$refs.form.validate((valid,done) => {
        if (valid) {
          const params = {
            plAreaType:parseInt(this.areaType),
            plContextOId:this.uiDefineData.plOId,
            ...this.form
          }
          if (this.dialogType === 'add') {
            addTabData(params).then(res => {
              if (res.data.code === 200) {
                this.$message.success('添加成功');
                this.dialogClose();
                this.getTableList();
              }
            })
          } else if (this.dialogType === 'edit') {
            updateTabData(params).then(res => {
              if (res.data.code === 200) {
                this.$message.success('修改成功');
                this.dialogClose()
                this.getTableList();
              }
            })
          }
        } else {
          return false;
        }
      });
    },
  }
}
</script>
 
<style scoped>
.tip{
  font-size: 12px;
  color: #909399;
  margin: -13px 0 10px 100px;
}
</style>