emis-frontend/src/views/emis/emisNotCalcAging/emisNotCalcAgingForm.vue

207 lines
6.1 KiB
Vue
Raw Normal View History

2024-01-10 07:38:42 +00:00
<template>
<div >
<el-row :gutter="0">
2024-04-22 05:33:25 +00:00
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-col :span="12">
2024-01-11 06:38:10 +00:00
<el-form-item label="不计时效日期" prop="noCalcDay">
2024-01-10 07:38:42 +00:00
<el-date-picker clearable
2024-01-11 06:38:10 +00:00
v-model="form.noCalcDay"
2024-01-10 07:38:42 +00:00
type="date"
value-format="yyyy-MM-dd"
2024-01-11 06:38:10 +00:00
placeholder="请选择不计时效日期">
2024-01-10 07:38:42 +00:00
</el-date-picker>
</el-form-item>
</el-col>
2024-04-22 05:33:25 +00:00
<el-col :span="12">
<el-form-item label="所属国家" prop="country">
<el-select v-model="form.country" multiple clearable filterable @change="onCountryChange" placeholder="所属国家" >
<el-option
v-for="item in countryIdsOptions"
:key="item.code"
:label="item.name"
:value="item.code"
:disabled="item.disabled"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="是否启用" prop="status">
<el-radio-group v-model="form.status">
<el-radio :label="1">是</el-radio>
<el-radio :label="0">否</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<!--
2024-01-11 06:38:10 +00:00
<el-col :span="24">
2024-01-10 07:38:42 +00:00
<el-form-item label="备注" prop="remark">
2024-01-11 06:38:10 +00:00
<el-input v-model="form.remark" placeholder="请输入备注" />
2024-01-10 07:38:42 +00:00
</el-form-item>
2024-01-11 06:38:10 +00:00
</el-col>
2024-04-22 05:33:25 +00:00
<el-col :span="24" v-show="moreInputVisible" > </el-col>
<el-col :span="24">
<el-divider content-position="right" @click="handleShowMoreInput" >更多信息[+]</el-divider>
</el-col>
-->
2024-01-10 07:38:42 +00:00
</el-form>
</el-row>
<div style="text-align: center;margin-bottom: 10px;">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</div>
</template>
<script>
import { listEmisNotCalcAging, getEmisNotCalcAging, delEmisNotCalcAging, addEmisNotCalcAging, updateEmisNotCalcAging } from "@/api/emis/emisNotCalcAging";
2024-04-22 05:33:25 +00:00
import { listEmisCountry, getEmisCountry, delEmisCountry, addEmisCountry, updateEmisCountry } from "@/api/emis/emisCountry";
2024-01-10 07:38:42 +00:00
export default {
name: "emisNotCalcAgingForm",
props:{
id:undefined
},
components: { },
dicts: [
'sys_normal_disable',
],
data() {
return {
emisNotCalcAgingOptions: [],
2024-04-22 05:33:25 +00:00
countryIdsOptions:[],
2024-01-10 07:38:42 +00:00
// 遮罩层
loading: true,
// 表单参数
form: {},
// 表单校验
rules: {
2024-01-11 06:38:10 +00:00
country: [
2024-04-22 05:33:25 +00:00
{ required: true, message: "所属国家不能为空", trigger: "blur" }
2024-01-11 06:38:10 +00:00
],
noCalcDay: [
{ required: true, message: "不计时效日期不能为空", trigger: "blur" }
2024-01-10 07:38:42 +00:00
],
2024-01-11 06:38:10 +00:00
status: [
{ required: true, message: "启用状态不能为空", trigger: "blur" }
2024-01-10 07:38:42 +00:00
],
}
};
},
watch: {
"id": {
handler (newValue, oldValue) {
this.id = newValue;
this.initData();
},
deep: true
}
},
created() {
this.initData();
2024-04-22 05:33:25 +00:00
this.initCountry();
2024-01-10 07:38:42 +00:00
},
methods: {
initData() {
this.reset();
if(this.id !=undefined) {
this.loading = true;
getEmisNotCalcAging(this.id).then(response => {
this.form = response.data;
2024-04-22 05:33:25 +00:00
if(this.form.country != null && this.form.country != ''){
this.form.country = this.form.country.split(',')
}
2024-01-10 07:38:42 +00:00
this.loading = false;
});
}
2024-04-22 05:33:25 +00:00
},
onCountryChange() {
console.log(this.form.country)
if (this.form.country.includes('-1')) {
console.log("0000=>"+this.form.country)
this.countryIdsOptions.map((res) => {
if(res.code != '-1'){
res.disabled = true;
}else{
res.disabled = false;
}
});
}else{
console.log("1111=>"+this.form.country)
this.countryIdsOptions.map((res) => {
if(res.code == '-1' && this.form.country.length>0){
res.disabled = true;
}else{
res.disabled = false;
}
});
}
// 数组的indexOf方法,会返回当前值在数组中的下标,没有则为-1
// if(this.form.country!=null && this.form.country!=undefined){
// }
// else {
// this.countryIdsOptions.map((res) => {
// res.disabled = false;
// });
// }
},
initCountry() {
this.countryIdsOptions = [{'code':'-1','name':'全部国家','nameEn':'ALL'}];
this.loading = true;
listEmisCountry(this.queryParams).then(response => {
this.loading = false;
this.countryIdsOptions = this.countryIdsOptions.concat(response.rows);
});
2024-01-10 07:38:42 +00:00
},
// 取消按钮
cancel() {
this.reset();
this.$emit("on-cancel");
},
// 表单重置
reset() {
this.form = {
id: null,
country: null,
2024-04-22 05:33:25 +00:00
countryName: null,
2024-01-11 06:38:10 +00:00
noCalcDay: null,
2024-01-10 07:38:42 +00:00
status: null,
remark: null,
tenantId: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
2024-04-22 05:33:25 +00:00
this.form.country = this.form.country.join(",");
2024-01-10 07:38:42 +00:00
if (this.form.id != null) {
updateEmisNotCalcAging(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
} else {
addEmisNotCalcAging(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
}
}
});
},
}
};
</script>