|
@@ -35,15 +35,29 @@
|
|
<el-radio-button label="justify">两端</el-radio-button>
|
|
<el-radio-button label="justify">两端</el-radio-button>
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item prop="field" label="字段:"> </el-form-item>
|
|
|
|
|
|
+ <el-form-item prop="field" label="字段:">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="modalForm.field"
|
|
|
|
+ placeholder="请选择"
|
|
|
|
+ @change="fieldChange"
|
|
|
|
+ >
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in FIELD_LIST"
|
|
|
|
+ :key="item.field"
|
|
|
|
+ :label="item.name"
|
|
|
|
+ :value="item.field"
|
|
|
|
+ ></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import SizeSelect from "../../components/common/SizeSelect";
|
|
|
|
-import ColorSelect from "../../components/common/ColorSelect";
|
|
|
|
-import FontFamilySelect from "../../components/common/FontFamilySelect";
|
|
|
|
|
|
+import SizeSelect from "../../../card/components/common/SizeSelect";
|
|
|
|
+import ColorSelect from "../../../card/components/common/ColorSelect";
|
|
|
|
+import FontFamilySelect from "../../../card/components/common/FontFamilySelect";
|
|
|
|
+import { FIELD_LIST } from "./model";
|
|
|
|
|
|
const initModalForm = {
|
|
const initModalForm = {
|
|
id: "",
|
|
id: "",
|
|
@@ -76,11 +90,12 @@ export default {
|
|
return {
|
|
return {
|
|
modalForm: { ...initModalForm },
|
|
modalForm: { ...initModalForm },
|
|
isBold: false,
|
|
isBold: false,
|
|
|
|
+ FIELD_LIST,
|
|
rules: {
|
|
rules: {
|
|
- contentStr: [
|
|
|
|
|
|
+ field: [
|
|
{
|
|
{
|
|
required: true,
|
|
required: true,
|
|
- message: "请输入文本内容",
|
|
|
|
|
|
+ message: "请选择字段",
|
|
trigger: "change",
|
|
trigger: "change",
|
|
},
|
|
},
|
|
],
|
|
],
|
|
@@ -92,40 +107,16 @@ export default {
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
initData(val) {
|
|
initData(val) {
|
|
- const contentStr = val.content
|
|
|
|
- .map((item) => {
|
|
|
|
- return item.type === "text"
|
|
|
|
- ? item.content
|
|
|
|
- : "${" + item.content + "}";
|
|
|
|
- })
|
|
|
|
- .join("");
|
|
|
|
- this.modalForm = { ...val, contentStr };
|
|
|
|
|
|
+ this.modalForm = { ...val };
|
|
this.isBold = val.fontWeight > 400;
|
|
this.isBold = val.fontWeight > 400;
|
|
},
|
|
},
|
|
boldChange(isBold) {
|
|
boldChange(isBold) {
|
|
this.modalForm.fontWeight = isBold ? 700 : 400;
|
|
this.modalForm.fontWeight = isBold ? 700 : 400;
|
|
},
|
|
},
|
|
- contentChange() {
|
|
|
|
- const constentStr = this.modalForm.contentStr;
|
|
|
|
- const rexp = new RegExp(/\$\{.+?\}/, "g");
|
|
|
|
- const variates = constentStr.match(rexp);
|
|
|
|
- const texts = constentStr.split(rexp);
|
|
|
|
- let contents = [];
|
|
|
|
-
|
|
|
|
- texts.forEach((text, index) => {
|
|
|
|
- if (text)
|
|
|
|
- contents.push({
|
|
|
|
- type: "text",
|
|
|
|
- content: text,
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- if (variates && variates[index])
|
|
|
|
- contents.push({
|
|
|
|
- type: "variate",
|
|
|
|
- content: variates[index].replace("${", "").replace("}", ""),
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- this.modalForm.content = contents;
|
|
|
|
|
|
+ fieldChange(val) {
|
|
|
|
+ const item = FIELD_LIST.find((elem) => elem.field === val);
|
|
|
|
+ this.modalForm.fieldName = item ? item.name : "";
|
|
|
|
+ this.modalForm.content = "$" + this.modalForm.fieldName;
|
|
},
|
|
},
|
|
async submit() {
|
|
async submit() {
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|