|
@@ -124,13 +124,33 @@
|
|
|
dictName="数学字符"
|
|
dictName="数学字符"
|
|
|
v-model="form.symbol"
|
|
v-model="form.symbol"
|
|
|
></DictSelection>
|
|
></DictSelection>
|
|
|
|
|
+ <!-- 选择类型: 用户输入后回车即可生成选项, 支持多选 -->
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="form.defaultValue"
|
|
|
|
|
- placeholder="请选择"
|
|
|
|
|
|
|
+ v-model="form.defaultValueList"
|
|
|
|
|
+ multiple
|
|
|
|
|
+ filterable
|
|
|
|
|
+ allow-create
|
|
|
|
|
+ default-first-option
|
|
|
|
|
+ placeholder="输入选项后回车生成,可多选"
|
|
|
class="ele-block"
|
|
class="ele-block"
|
|
|
|
|
+ style="width: calc(100% - 100px)"
|
|
|
|
|
+ @change="defaultValueListChange"
|
|
|
>
|
|
>
|
|
|
- <el-option label="TRUE" :value="'TRUE'" />
|
|
|
|
|
- <el-option label="FALSE" :value="'FALSE'" />
|
|
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in selectOptions"
|
|
|
|
|
+ :key="item"
|
|
|
|
|
+ :label="item"
|
|
|
|
|
+ :value="item"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div class="qp-opt-row">
|
|
|
|
|
+ <span class="qp-opt-text">{{ item }}</span>
|
|
|
|
|
+ <i
|
|
|
|
|
+ class="el-icon-close qp-opt-del"
|
|
|
|
|
+ title="删除该选项"
|
|
|
|
|
+ @click.stop="removeSelectOption(item)"
|
|
|
|
|
+ ></i>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-col>
|
|
</el-col>
|
|
@@ -389,6 +409,9 @@
|
|
|
defaultForm,
|
|
defaultForm,
|
|
|
form: { ...defaultForm },
|
|
form: { ...defaultForm },
|
|
|
|
|
|
|
|
|
|
+ // 选择类型(textType==2)的候选选项池, 用户可自主生成
|
|
|
|
|
+ selectOptions: [],
|
|
|
|
|
+
|
|
|
qualityStandardList: [],
|
|
qualityStandardList: [],
|
|
|
rules: {
|
|
rules: {
|
|
|
qualityStandardId: [
|
|
qualityStandardId: [
|
|
@@ -453,11 +476,37 @@
|
|
|
this.form.maxValue = '';
|
|
this.form.maxValue = '';
|
|
|
this.form.minValue = '';
|
|
this.form.minValue = '';
|
|
|
this.form.symbol = '';
|
|
this.form.symbol = '';
|
|
|
|
|
+ // 切换参数类型时清空默认值, 选择类型的选项一并清空
|
|
|
|
|
+ this.form.defaultValue = '';
|
|
|
|
|
+ this.$set(this.form, 'defaultValueList', []);
|
|
|
if (this.form.textType == 8) {
|
|
if (this.form.textType == 8) {
|
|
|
this.form.symbol = '=';
|
|
this.form.symbol = '=';
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ // 选择类型: 选中/生成选项时维护选项池, 并同步逗号拼接值到 defaultValue 提交字段
|
|
|
|
|
+ defaultValueListChange(val) {
|
|
|
|
|
+ const pool = [...this.selectOptions];
|
|
|
|
|
+ (val || []).forEach((item) => {
|
|
|
|
|
+ if (!pool.includes(item)) {
|
|
|
|
|
+ pool.push(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ this.selectOptions = pool;
|
|
|
|
|
+ this.form.defaultValue = (val || []).join(',');
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 选择类型: 删除候选选项(从池中移除; 若该选项已选中则一并从默认值去掉)
|
|
|
|
|
+ removeSelectOption(item) {
|
|
|
|
|
+ this.selectOptions = this.selectOptions.filter((v) => v !== item);
|
|
|
|
|
+ const next = (this.form.defaultValueList || []).filter(
|
|
|
|
|
+ (v) => v !== item
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(this.form, 'defaultValueList', next);
|
|
|
|
|
+ this.form.defaultValue = next.join(',');
|
|
|
|
|
+ this.$message.success(`选项「${item}」已删除`);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
defaultInput(value) {
|
|
defaultInput(value) {
|
|
|
console.log(this.form.symbol, '0000 symbol');
|
|
console.log(this.form.symbol, '0000 symbol');
|
|
|
if (this.form.textType !== '1') {
|
|
if (this.form.textType !== '1') {
|
|
@@ -485,6 +534,12 @@
|
|
|
if (!valid) {
|
|
if (!valid) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 选择类型: 以多选结果为准同步 defaultValue(逗号拼接)
|
|
|
|
|
+ if (this.form.textType == 2) {
|
|
|
|
|
+ this.form.defaultValue = (this.form.defaultValueList || []).join(
|
|
|
|
|
+ ','
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
if (!this.isUpdate) {
|
|
if (!this.isUpdate) {
|
|
|
delete this.form.id;
|
|
delete this.form.id;
|
|
@@ -586,6 +641,19 @@
|
|
|
if (this.data) {
|
|
if (this.data) {
|
|
|
const res = await getById(this.data.id);
|
|
const res = await getById(this.data.id);
|
|
|
this.$util.assignObject(this.form, { ...res.data });
|
|
this.$util.assignObject(this.form, { ...res.data });
|
|
|
|
|
+ // 选择类型: 把已保存的默认值拆成多选数组, 并回填候选选项池
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form,
|
|
|
|
|
+ 'defaultValueList',
|
|
|
|
|
+ this.form.textType == 2 && this.form.defaultValue
|
|
|
|
|
+ ? String(this.form.defaultValue).split(',')
|
|
|
|
|
+ : []
|
|
|
|
|
+ );
|
|
|
|
|
+ if (this.form.textType == 2) {
|
|
|
|
|
+ this.selectOptions = [...(this.form.defaultValueList || [])];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.selectOptions = [];
|
|
|
|
|
+ }
|
|
|
this.isUpdate = true;
|
|
this.isUpdate = true;
|
|
|
// 编辑模式下触发标准代码填充
|
|
// 编辑模式下触发标准代码填充
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
@@ -595,11 +663,14 @@
|
|
|
const code = await getCode('inspection_code');
|
|
const code = await getCode('inspection_code');
|
|
|
this.form.inspectionCode = code;
|
|
this.form.inspectionCode = code;
|
|
|
this.form.qualityStandardCode = '';
|
|
this.form.qualityStandardCode = '';
|
|
|
|
|
+ this.selectOptions = [];
|
|
|
|
|
+ this.$set(this.form, 'defaultValueList', []);
|
|
|
this.isUpdate = false;
|
|
this.isUpdate = false;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
this.$refs.form.clearValidate();
|
|
this.$refs.form.clearValidate();
|
|
|
this.form = { ...this.defaultForm };
|
|
this.form = { ...this.defaultForm };
|
|
|
|
|
+ this.selectOptions = [];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -625,3 +696,23 @@
|
|
|
display: flex !important;
|
|
display: flex !important;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss">
|
|
|
|
|
+/* 选择类型候选选项行: 下拉挂在 body 下, 需用全局样式 */
|
|
|
|
|
+.qp-opt-row {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+}
|
|
|
|
|
+.qp-opt-del {
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ margin-left: 8px;
|
|
|
|
|
+ padding: 2px;
|
|
|
|
|
+ color: #c0c4cc;
|
|
|
|
|
+
|
|
|
|
|
+ &:hover {
|
|
|
|
|
+ color: #f56c6c;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|