1129测试

This commit is contained in:
fz
2023-11-29 22:56:06 +08:00
parent c507f28f3f
commit b537bd958d
3 changed files with 28 additions and 12 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ export function updateTemplate(data) {
return request({ return request({
url: '/deptIdentify/updateTemplate', url: '/deptIdentify/updateTemplate',
method: 'post', method: 'post',
data: data params: data
}) })
} }
// 删除模板 // 删除模板
@@ -31,6 +31,7 @@
</template> </template>
<script> <script>
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import { updateTemplate } from "@/api/officialSeal/officialSeal"
export default { export default {
props: ["editVisable", "editData", "queryParams"], props: ["editVisable", "editData", "queryParams"],
dicts: ["template_type"], dicts: ["template_type"],
@@ -41,7 +42,7 @@ export default {
headers: { headers: {
Authorization: "Bearer " + getToken(), Authorization: "Bearer " + getToken(),
}, },
isImg: false, isImg: true,
filedata: {}, filedata: {},
flagBtn: false, flagBtn: false,
ruleForm: {}, ruleForm: {},
@@ -77,19 +78,32 @@ export default {
}, },
handleChange(file, fileList) { handleChange(file, fileList) {
this.isImg = file.type === '.doc' || '.docx'; this.isImg = file.type === '.doc' || '.docx';
this.fileList = fileList;
}, },
UploadUrl() { UploadUrl() {
return window.location.origin + "/API/deptIdentify/updateTemplate"; return window.location.origin + "/API/deptIdentify/updateTemplate";
}, },
submitUpload() { submitUpload() {
let that = this;
this.$refs['ruleForm'].validate((valid) => { this.$refs['ruleForm'].validate((valid) => {
if (valid) { if (valid) {
this.filedata.id = this.editData.id; if (that.fileList.length > 0) {
this.filedata.temName = this.ruleForm.temName; that.filedata.id = that.editData.id;
if (this.isImg) { that.filedata.temName = that.ruleForm.temName;
this.$refs.upload.submit(); if (that.isImg) {
that.$refs.upload.submit();
} else { } else {
this.$message.error('只能上传doc,docx格式的文件') that.$message.error('只能上传doc,docx格式的文件')
}
} else {
updateTemplate({
id: that.editData.id,
temName: that.ruleForm.temName
}).then(res => {
that.$message.success('修改成功');
that.$emit("cancelEdit");
that.$emit('getList', that.queryParams);
})
} }
} }
}); });
@@ -101,7 +115,7 @@ export default {
// this.isImg = file.type === '.doc' || '.docx' // this.isImg = file.type === '.doc' || '.docx'
}, },
handleSuccess() { handleSuccess() {
this.$message.success('上传成功'); this.$message.success('修改成功');
this.$emit("cancelEdit"); this.$emit("cancelEdit");
this.$emit('getList', this.queryParams); this.$emit('getList', this.queryParams);
} }
@@ -7,7 +7,7 @@
<el-input v-model="ruleForm.sealName"></el-input> <el-input v-model="ruleForm.sealName"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-upload class="avatar-uploader" :before-upload="beforeUpload" :on-success="handleSuccess" ref="upload" <el-upload class="avatar-uploader" accept="image/png" :before-upload="beforeUpload" :on-success="handleSuccess" ref="upload"
:action="UploadUrl()" :headers="headers" :data="filedata" :on-remove="handleRemove" :action="UploadUrl()" :headers="headers" :data="filedata" :on-remove="handleRemove"
:on-change="handleChange" :show-file-list="false" :file-list="fileList" :auto-upload="false"> :on-change="handleChange" :show-file-list="false" :file-list="fileList" :auto-upload="false">
<img v-if="imageUrl" :src="imageUrl" class="avatar"> <img v-if="imageUrl" :src="imageUrl" class="avatar">
@@ -47,7 +47,8 @@ export default {
watch: { watch: {
uploadVisable(val) { uploadVisable(val) {
if (val) { if (val) {
this.imageUrl = "" this.imageUrl = "",
this.ruleForm = {}
} }
} }
}, },
@@ -85,7 +86,8 @@ export default {
}, },
handleSuccess(response) { handleSuccess(response) {
if (response.code == 200) { if (response.code == 200) {
this.$message.success('上传成功') this.$message.success('上传成功');
this.cancel()
} else { } else {
this.$message.error(response.msg); this.$message.error(response.msg);
} }