|
@@ -10,7 +10,7 @@
|
|
|
添加样式
|
|
|
</el-button>
|
|
|
<!-- 样式表格 -->
|
|
|
- <el-table :data="[]" style="width: 100%">
|
|
|
+ <el-table :data="styleTableData" style="width: 100%">
|
|
|
<el-table-column label="序号" type="index" width="50"> </el-table-column>
|
|
|
<el-table-column prop="styleName" label="样式名" width="100">
|
|
|
</el-table-column>
|
|
@@ -28,7 +28,7 @@
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-edit"
|
|
|
- @click="() => {}"
|
|
|
+ @click="editHandler(scope.row, scope.$index)"
|
|
|
>修改
|
|
|
</el-button>
|
|
|
</el-dropdown-item>
|
|
@@ -37,7 +37,7 @@
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-delete"
|
|
|
- @click="() => {}"
|
|
|
+ @click="delHandler(scope.$index)"
|
|
|
>删除
|
|
|
</el-button>
|
|
|
</el-dropdown-item>
|
|
@@ -66,10 +66,11 @@
|
|
|
<el-radio-group v-model="styleFormData.styleType" size="small">
|
|
|
<el-radio-button :label="0">行样式</el-radio-button>
|
|
|
<el-radio-button :label="1">字段样式</el-radio-button>
|
|
|
+ <el-radio-button :label="2">字典样式</el-radio-button>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<template v-if="styleFormData.styleType == 0">
|
|
|
- <el-form-item label="字体颜色">
|
|
|
+ <el-form-item label="背景颜色">
|
|
|
<input
|
|
|
type="color"
|
|
|
:value="styleFormData.rowBgColor"
|
|
@@ -77,7 +78,51 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
- <template v-else>
|
|
|
+ <template v-else-if="styleFormData.styleType == 1">
|
|
|
+ <el-form-item label="样式生效字段">
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-select
|
|
|
+ v-model="styleFormData.styleTable"
|
|
|
+ value-key=""
|
|
|
+ placeholder="请选择表"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in tableList"
|
|
|
+ :key="item.tableName"
|
|
|
+ :label="item.tableComment"
|
|
|
+ :value="item.tableName"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{ item.tableComment }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{
|
|
|
+ item.tableName
|
|
|
+ }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-select
|
|
|
+ v-model="styleFormData.styleField"
|
|
|
+ value-key=""
|
|
|
+ placeholder="请选择字段"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in styleFieldList"
|
|
|
+ :key="item.fieldName"
|
|
|
+ :label="item.fieldDescription"
|
|
|
+ :value="item.fieldName"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{ item.fieldDescription }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{
|
|
|
+ item.fieldName
|
|
|
+ }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="文本样式">
|
|
|
<el-radio-group v-model="styleFormData.fieldStyleType" size="small">
|
|
|
<el-radio-button :label="0">普通文本</el-radio-button>
|
|
@@ -128,20 +173,90 @@
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
</template>
|
|
|
- <div class="condition-table-wrap">
|
|
|
+ <template v-else>
|
|
|
+ <el-form-item label="字典生效字段" size="normal">
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-select
|
|
|
+ v-model="styleFormData.styleTable"
|
|
|
+ value-key=""
|
|
|
+ placeholder="请选择表"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in tableList"
|
|
|
+ :key="item.tableName"
|
|
|
+ :label="item.tableComment"
|
|
|
+ :value="item.tableName"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{ item.tableComment }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{
|
|
|
+ item.tableName
|
|
|
+ }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-select
|
|
|
+ v-model="styleFormData.styleField"
|
|
|
+ value-key=""
|
|
|
+ placeholder="请选择字段"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in styleFieldList"
|
|
|
+ :key="item.fieldName"
|
|
|
+ :label="item.fieldDescription"
|
|
|
+ :value="item.fieldName"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{ item.fieldDescription }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{
|
|
|
+ item.fieldName
|
|
|
+ }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字典" size="normal">
|
|
|
+ <el-select
|
|
|
+ v-model="styleFormData.styleCondtion"
|
|
|
+ placeholder="请选择字典"
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in dictsList"
|
|
|
+ :key="item.dictType"
|
|
|
+ :label="item.dictName"
|
|
|
+ :value="item.dictType"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <div v-if="styleFormData.styleType != 2" class="condition-table-wrap">
|
|
|
<span class="table-title">条件编辑</span>
|
|
|
<el-table :data="conditionTableData" style="width: 100%">
|
|
|
<el-table-column label="序号" type="index" width="50">
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="tableKey" label="表名" width="150">
|
|
|
+ <el-table-column prop="tableName" label="表名" width="150">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-select v-model="scope.row.tableKey" placeholder="请选择">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.tableName"
|
|
|
+ @change="conditionTableChange(scope.row)"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
<el-option
|
|
|
- v-for="item in []"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
+ v-for="item in tableList"
|
|
|
+ :key="item.tableName"
|
|
|
+ :label="item.tableComment"
|
|
|
+ :value="item.tableName"
|
|
|
>
|
|
|
+ <span style="float: left">{{ item.tableComment }}</span>
|
|
|
+ <span
|
|
|
+ style="float: right; color: #8492a6; font-size: 13px"
|
|
|
+ >{{ item.tableName }}</span
|
|
|
+ >
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
@@ -150,11 +265,16 @@
|
|
|
<template slot-scope="scope">
|
|
|
<el-select v-model="scope.row.fieldName" placeholder="请选择">
|
|
|
<el-option
|
|
|
- v-for="item in []"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
+ v-for="item in scope.row.fieldList"
|
|
|
+ :key="item.fieldName"
|
|
|
+ :label="item.fieldDescription"
|
|
|
+ :value="item.fieldName"
|
|
|
>
|
|
|
+ <span style="float: left">{{ item.fieldDescription }}</span>
|
|
|
+ <span
|
|
|
+ style="float: right; color: #8492a6; font-size: 13px"
|
|
|
+ >{{ item.fieldName }}</span
|
|
|
+ >
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
@@ -191,7 +311,7 @@
|
|
|
size="mini"
|
|
|
type="danger"
|
|
|
icon="el-icon-delete"
|
|
|
- @click="() => {}"
|
|
|
+ @click="deleteConditionItem(scope.$index)"
|
|
|
>删除
|
|
|
</el-button>
|
|
|
</template>
|
|
@@ -203,32 +323,54 @@
|
|
|
icon="el-icon-plus"
|
|
|
size="mini"
|
|
|
style="width: 100%"
|
|
|
- @click="addDataDialog"
|
|
|
+ @click="addConditionHandler"
|
|
|
>
|
|
|
添加条件
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogShow = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="saveStyleFormHandler"
|
|
|
+ >确 定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { listType } from "@/api/system/tenant/type";
|
|
|
export default {
|
|
|
name: "StyleFormPanel",
|
|
|
- props: [],
|
|
|
+ props: {
|
|
|
+ tableFieldList: {
|
|
|
+ default: [],
|
|
|
+ type: Array,
|
|
|
+ },
|
|
|
+ dragTableStyleList: {
|
|
|
+ default: [],
|
|
|
+ type: Array,
|
|
|
+ },
|
|
|
+ },
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
dialogShow: false,
|
|
|
-
|
|
|
+ // 表格及字段数据
|
|
|
+ tableList: [],
|
|
|
+ isShowFieldList: [],
|
|
|
+ allFieldList: [],
|
|
|
+ editIndex: -1,
|
|
|
// 表格样式数据
|
|
|
styleTableData: [],
|
|
|
styleFormData: {
|
|
|
styleName: "",
|
|
|
styleDescription: "",
|
|
|
- styleType: 0, //0:行样式 1:字段样式
|
|
|
- tableKey: "",
|
|
|
+ styleType: 0, //0:行样式 1:字段样式 2:字典样式
|
|
|
+ styleTable: "", //样式生效的表
|
|
|
+ styleField: "", //样式生效的字段
|
|
|
+ tableName: "",
|
|
|
styleCode: "",
|
|
|
styleCondtion: "",
|
|
|
rowBgColor: "", //行背景色
|
|
@@ -236,20 +378,16 @@ export default {
|
|
|
fontColor: "", //字体颜色
|
|
|
isTagFullBg: false, //tag背景色是否填满
|
|
|
tagType: "",
|
|
|
-
|
|
|
- // styleCondtionObj: {
|
|
|
- // styleField: "", //样式生效字段
|
|
|
- // styleCondtionField: "", //样式条件依赖字段
|
|
|
- // styleCondtionList: [], //条件列表
|
|
|
- // },
|
|
|
+ conditionTableStr: "",
|
|
|
},
|
|
|
conditionTableData: [
|
|
|
- {
|
|
|
- tableKey: "",
|
|
|
- fieldName: "",
|
|
|
- condition: 1, //1:> 2:< 3:= 4:>= 5:<=
|
|
|
- flagValue: 0,
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // tableName: "",
|
|
|
+ // fieldName: "",
|
|
|
+ // condition: 1, //1:> 2:< 3:= 4:>= 5:<=
|
|
|
+ // flagValue: 0,
|
|
|
+ // fieldList: [],
|
|
|
+ // },
|
|
|
],
|
|
|
conditionList: [
|
|
|
{
|
|
@@ -295,20 +433,203 @@ export default {
|
|
|
label: "危险",
|
|
|
},
|
|
|
],
|
|
|
+ // 字典列表
|
|
|
+ dictsList: [],
|
|
|
};
|
|
|
},
|
|
|
- computed: {},
|
|
|
+ computed: {
|
|
|
+ styleFieldList() {
|
|
|
+ return this.isShowFieldList.filter(
|
|
|
+ (item) => item.tableName == this.styleFormData.styleTable
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ tableFieldList: {
|
|
|
+ handler(nval) {
|
|
|
+ if (!nval || !nval.length) return;
|
|
|
+ this.allFieldList = nval;
|
|
|
+ this.isShowFieldList = nval.filter((item) => item.isShow);
|
|
|
+ let tempList = nval.map((item) => {
|
|
|
+ return {
|
|
|
+ tableName: item.tableName,
|
|
|
+ tableComment: item.tableComment,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this.tableList = [];
|
|
|
+ tempList.forEach((item) => {
|
|
|
+ let isHas = this.tableList.find(
|
|
|
+ (it) => it.tableName == item.tableName
|
|
|
+ );
|
|
|
+ if (!isHas) {
|
|
|
+ this.tableList.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ dragTableStyleList: {
|
|
|
+ handler(nval) {
|
|
|
+ let res = nval.map((item) => {
|
|
|
+ let tampItem = JSON.parse(JSON.stringify(item));
|
|
|
+ let styleCode = JSON.parse(tampItem.styleCode);
|
|
|
+ let { rowBgColor, fieldStyleType, fontColor, isTagFullBg, tagType } =
|
|
|
+ styleCode;
|
|
|
+ let fieldData = tampItem.styleField?.split(".");
|
|
|
+ Object.assign(tampItem, {
|
|
|
+ rowBgColor,
|
|
|
+ fieldStyleType,
|
|
|
+ fontColor,
|
|
|
+ isTagFullBg,
|
|
|
+ tagType,
|
|
|
+ conditionTableStr: tampItem.styleCondtion,
|
|
|
+ styleTable: fieldData ? fieldData[0] : "",
|
|
|
+ styleField: fieldData ? fieldData[1] : "",
|
|
|
+ });
|
|
|
+ return tampItem;
|
|
|
+ });
|
|
|
+ this.styleTableData = res;
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
// 添加一条样式数据回调
|
|
|
- addDataDialog() {
|
|
|
+ addDataDialog(index, row) {
|
|
|
+ this.resetStyleFormData();
|
|
|
this.dialogShow = true;
|
|
|
},
|
|
|
|
|
|
+ // 重置样式表单
|
|
|
+ resetStyleFormData() {
|
|
|
+ Object.assign(this.styleFormData, {
|
|
|
+ styleName: "",
|
|
|
+ styleDescription: "",
|
|
|
+ styleType: 0,
|
|
|
+ tableName: "",
|
|
|
+ styleCode: "",
|
|
|
+ styleCondtion: "",
|
|
|
+ rowBgColor: "",
|
|
|
+ fieldStyleType: 0,
|
|
|
+ fontColor: "",
|
|
|
+ isTagFullBg: false,
|
|
|
+ tagType: "",
|
|
|
+ styleTable: "",
|
|
|
+ styleField: "",
|
|
|
+ });
|
|
|
+ this.conditionTableData = [];
|
|
|
+ },
|
|
|
+
|
|
|
+ //样式表单保存回调
|
|
|
+ saveStyleFormHandler() {
|
|
|
+ this.$refs.styleFormDataRef.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let tempConditionTableData = this.conditionTableData.map((item) => ({
|
|
|
+ tableName: item.tableName,
|
|
|
+ fieldName: item.fieldName,
|
|
|
+ condition: item.condition,
|
|
|
+ flagValue: item.flagValue,
|
|
|
+ }));
|
|
|
+ this.styleFormData.conditionTableStr = JSON.stringify(
|
|
|
+ tempConditionTableData
|
|
|
+ );
|
|
|
+ let tempFormData = JSON.parse(JSON.stringify(this.styleFormData));
|
|
|
+ console.log(tempFormData, this.editIndex);
|
|
|
+ if (this.editIndex != -1) {
|
|
|
+ //修改
|
|
|
+ this.$set(this.styleTableData, this.editIndex, tempFormData);
|
|
|
+ // this.styleTableData[this.editIndex] = tempFormData;
|
|
|
+ this.editIndex = -1;
|
|
|
+ } else {
|
|
|
+ //新增
|
|
|
+ this.styleTableData.push(tempFormData);
|
|
|
+ }
|
|
|
+ console.log(this.styleTableData);
|
|
|
+ this.dialogShow = false;
|
|
|
+ } else {
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //添加样式判断条件回调
|
|
|
+ addConditionHandler() {
|
|
|
+ this.conditionTableData.push({
|
|
|
+ tableName: "",
|
|
|
+ fieldName: "",
|
|
|
+ condition: 1, //1:> 2:< 3:= 4:>= 5:<=
|
|
|
+ flagValue: 0,
|
|
|
+ fieldList: [],
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
// 颜色改变回调
|
|
|
selectColors(event, tempField) {
|
|
|
console.log(tempField);
|
|
|
this.styleFormData[tempField] = event.target.value;
|
|
|
},
|
|
|
+
|
|
|
+ // 条件表改变回调
|
|
|
+ conditionTableChange(row) {
|
|
|
+ if (!row.tableName) return;
|
|
|
+ row.fieldList = this.allFieldList.filter(
|
|
|
+ (item) => item.tableName == row.tableName
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
+ // 条件表删除回调
|
|
|
+ deleteConditionItem(index) {
|
|
|
+ this.conditionTableData.splice(index, 1);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 编辑样式回调
|
|
|
+ editHandler(row, index) {
|
|
|
+ this.editIndex = index;
|
|
|
+ this.styleFormData = JSON.parse(JSON.stringify(row));
|
|
|
+ console.log(row.conditionTableStr);
|
|
|
+ if (row.styleType != 2) {
|
|
|
+ this.conditionTableData = JSON.parse(row.conditionTableStr);
|
|
|
+ this.conditionTableData.forEach((item) => {
|
|
|
+ this.conditionTableChange(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.dialogShow = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除样式回调
|
|
|
+ delHandler(index) {
|
|
|
+ this.styleTableData.splice(index, 1);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取保存数据
|
|
|
+ getSaveData() {
|
|
|
+ let res = this.styleTableData.map((item) => {
|
|
|
+ let styleCode = {
|
|
|
+ rowBgColor: item.rowBgColor,
|
|
|
+ fieldStyleType: item.fieldStyleType,
|
|
|
+ fontColor: item.fontColor,
|
|
|
+ isTagFullBg: item.isTagFullBg,
|
|
|
+ tagType: item.tagType,
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ styleName: item.styleName,
|
|
|
+ styleDescription: item.styleDescription,
|
|
|
+ styleCode: JSON.stringify(styleCode),
|
|
|
+ styleCondtion:
|
|
|
+ item.styleType == 2 ? item.styleCondtion : item.conditionTableStr,
|
|
|
+ styleField: item.styleTable + "." + item.styleField,
|
|
|
+ styleType: item.styleType,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ async mounted() {
|
|
|
+ let res = await listType(this.addDateRange({ isEnablePaging: false }, []));
|
|
|
+ this.dictsList = res.rows;
|
|
|
},
|
|
|
};
|
|
|
</script>
|