|
@@ -24,22 +24,51 @@
|
|
|
label-width="80px"
|
|
|
class="demo-ruleForm"
|
|
|
>
|
|
|
- <el-form-item label="名称" prop="name">
|
|
|
- <el-input
|
|
|
- v-model="ruleForm['name']"
|
|
|
- :disabled="id == '007'"
|
|
|
- placeholder="名称"
|
|
|
- maxlength="20"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="数据类型" prop="type">
|
|
|
+ <el-select
|
|
|
+ v-model="ruleForm.type"
|
|
|
+ style="width: 100%"
|
|
|
+ :disabled="id == '007'"
|
|
|
+ placeholder="数据类型"
|
|
|
+ @change="typeChange"
|
|
|
+ >
|
|
|
+ <el-option label="面积1~面积2 ㎡" value="1" />
|
|
|
+ <el-option label="面积+ ㎡" value="2" />
|
|
|
+ </el-select> </el-form-item
|
|
|
+ ></el-col>
|
|
|
+ <el-col :span="ruleForm.type === '1' ? 13 : 24">
|
|
|
+ <el-form-item label="会议面积" prop="min">
|
|
|
+ <el-input
|
|
|
+ v-model="ruleForm['min']"
|
|
|
+ :disabled="id == '007'"
|
|
|
+ placeholder="面积1"
|
|
|
+ maxlength="20"
|
|
|
+ >
|
|
|
+ <template slot="append" v-if="ruleForm.type !== '1'">+</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="2" class="tc" v-if="ruleForm.type === '1'">
|
|
|
+ <span style="height: 40px; line-height: 40px">~</span>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="9" v-if="ruleForm.type === '1'">
|
|
|
+ <el-form-item label-width="0" prop="max">
|
|
|
+ <el-input
|
|
|
+ v-model="ruleForm['max']"
|
|
|
+ :disabled="id == '007'"
|
|
|
+ placeholder="面积2"
|
|
|
+ maxlength="20"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</el-form>
|
|
|
</el-col>
|
|
|
<el-col :span="24" style="text-align: right">
|
|
|
- <el-button
|
|
|
- v-if="id !== '007'"
|
|
|
- type="primary"
|
|
|
- @click="submitForm"
|
|
|
- >保 存
|
|
|
+ <el-button v-if="id !== '007'" type="primary" @click="submitForm"
|
|
|
+ >保 存
|
|
|
</el-button>
|
|
|
<el-button @click="showModelThis = false">{{
|
|
|
id == "007" ? "关 闭" : "取 消"
|
|
@@ -50,107 +79,121 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import asyncRequest from '@/apis/service/serviceParam/actNum'
|
|
|
-import resToken from '@/mixins/resToken'
|
|
|
+import asyncRequest from "@/apis/service/serviceParam/actNum";
|
|
|
+import resToken from "@/mixins/resToken";
|
|
|
|
|
|
/**
|
|
|
* @props
|
|
|
* 名称 name
|
|
|
* */
|
|
|
export default {
|
|
|
- name: 'Brand',
|
|
|
+ name: "actNum",
|
|
|
mixins: [resToken],
|
|
|
- props: ['showModel', 'id', 'sitem'],
|
|
|
+ props: ["showModel", "id", "sitem"],
|
|
|
data() {
|
|
|
return {
|
|
|
loading: false,
|
|
|
- title: '添加活动人数',
|
|
|
+ title: "添加活动人数",
|
|
|
showModelThis: this.showModel,
|
|
|
- select: '1',
|
|
|
+ select: "1",
|
|
|
activeOptions: [],
|
|
|
actionList: [],
|
|
|
ruleForm: {
|
|
|
- id: '',
|
|
|
- 名称:""
|
|
|
+ id: "",
|
|
|
+ type: "1",
|
|
|
+ min: "",
|
|
|
+ max: "",
|
|
|
},
|
|
|
rulesThis: this.rules,
|
|
|
rules: {
|
|
|
- name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
|
|
|
- }
|
|
|
- }
|
|
|
+ type: [{ required: true, message: "请选择数据类型", trigger: "change" }],
|
|
|
+ min: [{ required: true, message: "最小面积不能为空", trigger: "blur" }],
|
|
|
+ max: [{ required: true, message: "最大面积不能为空", trigger: "blur" }],
|
|
|
+ },
|
|
|
+ };
|
|
|
},
|
|
|
watch: {
|
|
|
- showModel: function(val) {
|
|
|
- this.showModelThis = val
|
|
|
+ showModel: function (val) {
|
|
|
+ this.showModelThis = val;
|
|
|
if (val) {
|
|
|
- this.initForm()
|
|
|
+ this.initForm();
|
|
|
}
|
|
|
},
|
|
|
showModelThis(val) {
|
|
|
if (!val) {
|
|
|
- this.$emit('cancel')
|
|
|
+ this.$emit("cancel");
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
async initForm() {
|
|
|
- this.loading = true
|
|
|
- const basicTitle = '活动人数'
|
|
|
- let prefix = this.id === '005' ? '修改' : this.id === '002' ? '添加' : ''
|
|
|
- this.title = prefix ? prefix + basicTitle : basicTitle + '详情'
|
|
|
- await this.resetForm()
|
|
|
- this.loading = false
|
|
|
+ this.loading = true;
|
|
|
+ const basicTitle = "活动人数";
|
|
|
+ let prefix = this.id === "005" ? "修改" : this.id === "002" ? "添加" : "";
|
|
|
+ this.title = prefix ? prefix + basicTitle : basicTitle + "详情";
|
|
|
+ await this.resetForm();
|
|
|
+ this.loading = false;
|
|
|
},
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
|
if (this.$refs.ruleForm) {
|
|
|
- this.$refs.ruleForm.resetFields()
|
|
|
- this.$refs.ruleForm.clearValidate()
|
|
|
- const { id, name } = this.sitem
|
|
|
+ this.$refs.ruleForm.resetFields();
|
|
|
+ this.$refs.ruleForm.clearValidate();
|
|
|
+ const { id, min, max } = this.sitem;
|
|
|
+ const isok = String(max) === "0";
|
|
|
this.ruleForm = {
|
|
|
- id: id || '',
|
|
|
- name: name || ''
|
|
|
- }
|
|
|
+ id: id || "",
|
|
|
+ type: isok ? "2" : "1",
|
|
|
+ min: min || "",
|
|
|
+ max: max || "",
|
|
|
+ };
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ typeChange() {
|
|
|
+ const { type } = this.ruleForm;
|
|
|
+ this.rulesThis.max[0].required = type === "1";
|
|
|
},
|
|
|
async submitForm() {
|
|
|
- await this.$refs.ruleForm.validate(async(valid) => {
|
|
|
+ await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
if (!this.loading) {
|
|
|
- this.loading = true
|
|
|
- const model = JSON.parse(JSON.stringify(this.ruleForm))
|
|
|
- let res = {}
|
|
|
- if (this.id === '002') {
|
|
|
- delete model['id']
|
|
|
- res = await asyncRequest.add(model)
|
|
|
+ this.loading = true;
|
|
|
+ let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
+ if (model.type === "2") {
|
|
|
+ model.max = "";
|
|
|
+ }
|
|
|
+ let res = {};
|
|
|
+ if (this.id === "002") {
|
|
|
+ delete model["id"];
|
|
|
+ res = await asyncRequest.add(model);
|
|
|
} else {
|
|
|
- res = await asyncRequest.update(model)
|
|
|
+ res = await asyncRequest.update(model);
|
|
|
}
|
|
|
- this.loading = false
|
|
|
+ this.loading = false;
|
|
|
if (res && res.code === 1) {
|
|
|
- const title = this.id === '002' ? '添加成功!' : '修改成功!'
|
|
|
+ const title = this.id === "002" ? "添加成功!" : "修改成功!";
|
|
|
this.$notify.success({
|
|
|
title,
|
|
|
- message: ''
|
|
|
- })
|
|
|
- this.showModelThis = false
|
|
|
+ message: "",
|
|
|
+ });
|
|
|
+ this.showModelThis = false;
|
|
|
// 刷新
|
|
|
- this.$emit('refresh')
|
|
|
- }
|
|
|
+ this.$emit("refresh");
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('error submit!!')
|
|
|
- return false
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.brand {
|
|
|
+.actNum {
|
|
|
}
|
|
|
</style>
|