- 修改弹窗标题为“修改”,并移除链接地址输入项 - 更新表单数据结构,确保只保留分类信息 - 添加同步按钮,替换新增按钮,优化用户操作流程 - 实现同步弹窗的显示逻辑,支持数据列表的刷新
144 lines
3.6 KiB
Vue
144 lines
3.6 KiB
Vue
<template>
|
|
<el-dialog
|
|
width="1260px"
|
|
title="修改"
|
|
:close-on-click-modal="false"
|
|
:visible.sync="visible"
|
|
@close="handlereset"
|
|
style="height: auto;"
|
|
>
|
|
<div style="margin-bottom: 60px;">
|
|
<el-form
|
|
style="height: auto;"
|
|
class="addFormBox"
|
|
:model="dataForm"
|
|
:rules="dataRule"
|
|
ref="dataForm"
|
|
label-width="80px"
|
|
>
|
|
<el-form-item label="分类" prop="type">
|
|
<el-select v-model="dataForm.type" placeholder="请选择分类" clearable>
|
|
<el-option
|
|
v-for="item in typeList"
|
|
:key="item.dictType"
|
|
:label="item.dictValue"
|
|
:value="item.dictType"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button @click="handlereset">取消</el-button>
|
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import global from "../../common/common.vue";
|
|
export default {
|
|
data() {
|
|
return {
|
|
baseUrl: global.baseUrl,
|
|
visible: false,
|
|
dialogImageUrl: "",
|
|
dialogVisible: false,
|
|
typeList: [],
|
|
dataForm: {
|
|
id: null,
|
|
type: ""
|
|
},
|
|
dataRule: {
|
|
type: [
|
|
{ required: true, message: "分类不能为空", trigger: "change" }
|
|
]
|
|
},
|
|
urlList: {
|
|
info: "/master/message/getMessageById",
|
|
update: "/common/wxPublicAccount/updateWxPublicAccountArticle"
|
|
}
|
|
};
|
|
},
|
|
methods: {
|
|
getTypeList() {
|
|
this.$http({
|
|
url: this.$http.adornUrl("/book/sysdictdata/selectByType/psycheForumLabel"),
|
|
method: "get"
|
|
}).then(({ data }) => {
|
|
if (data && data.code === 0) {
|
|
this.typeList = data.dataList || [];
|
|
} else {
|
|
this.typeList = [];
|
|
}
|
|
});
|
|
},
|
|
init(row) {
|
|
this.getTypeList();
|
|
this.dataForm = {
|
|
id: row && row.id || null,
|
|
type: row && row.type != null ? String(row.type) : ""
|
|
};
|
|
this.visible = true;
|
|
this.$nextTick(() => {
|
|
if (this.$refs["dataForm"]) {
|
|
this.$refs["dataForm"].clearValidate();
|
|
}
|
|
});
|
|
},
|
|
dataFormSubmit() {
|
|
this.$refs["dataForm"].validate(valid => {
|
|
if (valid) {
|
|
const loading = this.$loading({
|
|
lock: true,
|
|
fullscreen: true
|
|
});
|
|
this.$http
|
|
.request({
|
|
url: this.$http.adornUrl(this.urlList.update),
|
|
method: "POST",
|
|
data: this.dataForm,
|
|
header: {
|
|
"Content-Type": "application/json"
|
|
}
|
|
})
|
|
.then(({ data }) => {
|
|
loading.close();
|
|
if (data && data.code === 0) {
|
|
this.$message({
|
|
message: "操作成功",
|
|
type: "success",
|
|
duration: 1500,
|
|
onClose: () => {
|
|
this.visible = false;
|
|
this.$emit("refreshDataList");
|
|
}
|
|
});
|
|
} else {
|
|
this.$message.error(data.msg);
|
|
}
|
|
})
|
|
.catch(() => {
|
|
loading.close();
|
|
});
|
|
}
|
|
});
|
|
},
|
|
handlereset() {
|
|
if (this.$refs["dataForm"]) {
|
|
this.$refs["dataForm"].clearValidate();
|
|
}
|
|
this.visible = false;
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
/deep/ .addFormBox.el-form-item {
|
|
margin-bottom: 10px !important;
|
|
}
|
|
</style>
|