|
|
@@ -29,10 +29,12 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" v-if='form.newsType === "6"'>
|
|
|
- <el-form-item label="选择省份" prop="publishTime">
|
|
|
- <el-select v-model="introduction" placeholder="选择省份" multiple style="width: 240px">
|
|
|
+ <el-form-item label="选择省份" prop="introduction">
|
|
|
+ <el-select v-model="introduction" placeholder="选择省份" multiple style="width: 240px"
|
|
|
+ @change="changeProvince" @remove-tag="removeProvince">
|
|
|
<el-option v-for="item in options" :key="item.value" :label="item.label"
|
|
|
- :value="item.value" :disabled="item.disabled && !introduction.includes(item.value)" />
|
|
|
+ :value="item.value"
|
|
|
+ :disabled="item.disabled && !introduction.includes(item.value)" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -105,7 +107,10 @@ const form = ref<any>({
|
|
|
const introduction = ref([]);
|
|
|
const rules = reactive({
|
|
|
newsTitle: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
|
|
- newsContent: [{ required: true, message: '请输入内容', trigger: 'blur' }]
|
|
|
+ newsContent: [{ required: true, message: '请输入内容', trigger: 'blur' }],
|
|
|
+ introduction: [{
|
|
|
+ required: false, trigger: 'change', message: '请选择省份',
|
|
|
+ }]
|
|
|
});
|
|
|
const formRef = ref();
|
|
|
const varietyOptions = ref([]);
|
|
|
@@ -146,9 +151,24 @@ const options = ref([
|
|
|
{ value: '香港', label: '香港', disabled: false },
|
|
|
{ value: '澳门', label: '澳门', disabled: false }
|
|
|
])
|
|
|
+const removeProvince = (e) => {
|
|
|
+ options.value.forEach((item) => {
|
|
|
+ if (item.value === e) {
|
|
|
+ item.disabled = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+const changeProvince = () => {
|
|
|
+ form.value.extraInfo.introduction = introduction.value.join(';;');
|
|
|
+ if (!form.value.extraInfo.introduction) {
|
|
|
+ rules.introduction[0].required = true
|
|
|
+ } else {
|
|
|
+ rules.introduction[0].required = false
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
const save = debounce(async () => {
|
|
|
await formRef.value.validate();
|
|
|
- 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);
|
|
|
@@ -156,7 +176,7 @@ const save = debounce(async () => {
|
|
|
}, 500);
|
|
|
|
|
|
const submitGround = debounce(async () => {
|
|
|
- await formRef.value.validate();
|
|
|
+ await formRef.value.validate('introduction');
|
|
|
const res = form.value.id ? await editNews(form.value) : await addNews(form.value);
|
|
|
if (res && res.code === 200) {
|
|
|
await publishNews(res.data.id);
|