|
|
@@ -30,9 +30,9 @@
|
|
|
</el-col>
|
|
|
<el-col :span="8" v-if='form.newsType === "6"'>
|
|
|
<el-form-item label="选择省份" prop="publishTime">
|
|
|
- <el-select v-model="form.extraInfo.introduction" placeholder="选择省份" style="width: 240px">
|
|
|
+ <el-select v-model="introduction" placeholder="选择省份" multiple style="width: 240px">
|
|
|
<el-option v-for="item in options" :key="item.value" :label="item.label"
|
|
|
- :value="item.value" :disabled="item.disabled" />
|
|
|
+ :value="item.value" :disabled="item.disabled && !introduction.includes(item.value)" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -99,9 +99,10 @@ const form = ref<any>({
|
|
|
newsOrigin: '',
|
|
|
extraInfo: {
|
|
|
accessory: [],
|
|
|
- introduction:''
|
|
|
+ introduction: ''
|
|
|
}
|
|
|
});
|
|
|
+const introduction = ref([]);
|
|
|
const rules = reactive({
|
|
|
newsTitle: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
|
|
newsContent: [{ required: true, message: '请输入内容', trigger: 'blur' }]
|
|
|
@@ -147,8 +148,7 @@ const options = ref([
|
|
|
])
|
|
|
const save = debounce(async () => {
|
|
|
await formRef.value.validate();
|
|
|
- console.log(form.value);
|
|
|
-
|
|
|
+ form.value.extraInfo.introduction = introduction.value.join(';;');
|
|
|
const res = form.value.id ? await editNews(form.value) : await addNews(form.value);
|
|
|
if (res && res.code === 200) {
|
|
|
router.go(-1);
|
|
|
@@ -168,7 +168,8 @@ const fetchDetail = async (id) => {
|
|
|
if (res && res.code === 200) {
|
|
|
form.value = res.data;
|
|
|
if (route.query?.newsType === '6') {
|
|
|
- form.value.extraInfo.introduction = res.data.extraInfo.introduction
|
|
|
+ const intro = form.value.extraInfo.introduction || '';
|
|
|
+ introduction.value.push(...(intro.includes(';;') ? intro.split(';;') : [intro]));
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -180,13 +181,12 @@ const getList = async () => {
|
|
|
});
|
|
|
res.rows.forEach(item => {
|
|
|
options.value.forEach(element => {
|
|
|
- if (element.value === item.extraInfo.introduction) {
|
|
|
- element.disabled = true
|
|
|
+ const introParts = item.extraInfo.introduction.split(';;');
|
|
|
+ if (introParts.some(part => part === element.value)) {
|
|
|
+ element.disabled = true;
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
- console.log(options.value);
|
|
|
-
|
|
|
};
|
|
|
const disable = ref(false);
|
|
|
const route = useRoute();
|
|
|
@@ -196,6 +196,6 @@ onMounted(() => {
|
|
|
// 编辑
|
|
|
fetchDetail(route.query?.id);
|
|
|
getList()
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
</script>
|