Browse Source

fix: 修复动物防治bug

sy-water-data-board-ui
panyuyi 1 year ago
parent
commit
1ee975795c
  1. 251
      src/views/dike/runManage/pestAnimalControl/governanceRecords/index.vue

251
src/views/dike/runManage/pestAnimalControl/governanceRecords/index.vue

@ -17,6 +17,8 @@ import {
updateDikeAnimalRecordStatus,
} from "@/api/dike";
import { uploadFileData } from "@/api/system/upload";
export default {
name: "InspectionItems",
data() {
@ -80,9 +82,9 @@ export default {
drugs: [{ drugName: "", concentration: "", dose: "" }], //
},
planRules: {
planId: [{ required: true, message: "请选择计划", trigger: "blur" }],
planId: [{ required: true, message: "请选择计划", trigger: "change" }],
dikeCode: [
{ required: true, message: "请选择堤防名称", trigger: "blur" },
{ required: true, message: "请选择堤防名称", trigger: "change" },
],
type: [{ required: true, message: "请选择计划", trigger: "change" }],
month: [{ required: true, message: "请选择月份", trigger: "change" }],
@ -176,14 +178,12 @@ export default {
},
//
handleConfirm(row) {
console.log("row >>>>> ", row);
this.$confirm("是否确认?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
console.log("?????????");
updateDikeAnimalRecordStatus({
id: row.id,
status: "1",
@ -199,71 +199,70 @@ export default {
},
//
viewOrEditPlanDetails(row, edit = false) {
this.handleGetRemotePlanData("");
if (!edit) {
this.prohibitEditing = true;
}
getDFMaintenancePlan(row.id).then((res) => {
getDFPreventionControlPlan(row.planId).then((res) => {
if (res.data) {
this.planForm = res.data;
this.planForm.planName = res.data.name;
this.planForm.planId = res.data.id;
this.planForm.selectUser = res.data.otherConfig.selectUser;
// this.planForm.reminderCycle = res.data.instruction + res.data.month; // ??????
this.dialogVisible = true;
this.recordForm.id = row.id;
}
});
getDikeAnimalRecordDetails(row.id).then((res) => {
this.recordForm.id = row.id;
this.recordForm = res.data || this.recordForm;
});
},
handleRemove(file) {
console.log(file);
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.imageDialog = true;
},
handleDownload(file) {
console.log(file);
console.log("查看 >>>> ", this.planList);
},
//
submitForm(formName) {
console.log("this.planForm >>>>> ", this.planForm);
this.$refs[formName].validate((valid) => {
if (valid) {
if (this.planForm.id) {
updateDikeAnimalRecordData({
planId: this.planForm.planId,
planName: this.planForm.name,
id: this.$route.query.id,
dikeCode: this.$route.query.dikeCode,
...this.recordForm,
}).then(() => {
this.getTableData();
this.dialogVisible = false;
this.$message({
message: "保存成功",
type: "success",
});
});
} else {
addDikeAnimalRecordData({
planId: this.planForm.planId,
planName: this.planForm.name,
id: null,
status: "0",
dikeCode: this.$route.query.dikeCode,
...this.recordForm,
}).then(() => {
this.getTableData();
this.dialogVisible = false;
this.$message({
message: "保存成功",
type: "success",
});
});
}
} else {
console.log("校验不通过");
return false;
submitForm() {
this.$refs.planForm.validate((v) => {
if (v) {
this.$refs.recordForm.validate((valid) => {
if (valid) {
if (this.planForm.id) {
updateDikeAnimalRecordData({
planId: this.planForm.planId,
planName: this.planForm.name,
id: this.$route.query.id,
dikeCode: this.$route.query.dikeCode,
...this.recordForm,
}).then(() => {
this.getTableData();
this.dialogVisible = false;
this.$message({
message: "保存成功",
type: "success",
});
});
} else {
addDikeAnimalRecordData({
planId: this.planForm.planId,
planName: this.planForm.name,
id: null,
status: "0",
dikeCode: this.$route.query.dikeCode,
...this.recordForm,
}).then(() => {
this.getTableData();
this.dialogVisible = false;
this.$message({
message: "保存成功",
type: "success",
});
});
}
} else {
console.log("校验不通过");
return false;
}
});
}
});
},
@ -273,9 +272,9 @@ export default {
this.dialogVisible = false;
},
// dialog
closeDialog(planForm = "planForm") {
console.log("触发关闭dialog", planForm);
this.$refs[planForm].resetFields();
closeDialog() {
this.$refs.recordForm.resetFields();
this.$refs.planForm.resetFields();
this.planForm = {
dikeCode: "",
name: "",
@ -285,6 +284,15 @@ export default {
location: "",
content: "",
};
this.recordForm = {
id: null,
location: "",
constructionStatus: "",
pest: null,
images: [],
remark: "",
drugs: [{ drugName: "", concentration: "", dose: "" }], //
};
},
//
addWorkItem() {
@ -346,7 +354,6 @@ export default {
changeDikePlan(planId) {
if (planId) {
getDFPreventionControlPlan(planId).then((res) => {
console.log("res >>>>> ", res);
if (res?.data) {
const { data } = res;
this.planForm.dikeCode = data.dikeCode;
@ -364,6 +371,30 @@ export default {
});
}
},
//
beforeUpload(e) {
if (this.recordForm.images?.length >= 10) {
this.$message.warning("最多上传10张图片");
return false;
}
return true;
},
handleUpload(e) {
const { file } = e;
let fData = new FormData();
fData.append("file", file);
uploadFileData(fData)
.then((res) => {
this.recordForm.images?.push(res.url);
})
.catch((err) => {
console.log("err >>>>> ", err);
});
},
//
handleDelImages(index) {
this.recordForm.images.splice(index, 1);
},
},
mounted() {
this.getDicts("dh_jh_type").then((res) => {
@ -471,9 +502,9 @@ export default {
>编辑</el-button
>
<el-button
style="margin-right: 9px"
type="text"
size="small"
v-if="scope.row.status == '0'"
@click="handleConfirm(scope.row)"
v-hasPermi="['df:run:fz:record:confirm']"
>确认</el-button
@ -487,7 +518,7 @@ export default {
@confirm="deleteTableItem(scope.row)"
>
<el-button
style="color: red"
style="color: red; margin-left: 9px"
type="text"
size="small"
slot="reference"
@ -888,39 +919,51 @@ export default {
</el-table-column>
</el-table>
<el-form-item label-width="120px" label="上传图片" prop="images">
<el-upload action="#" list-type="picture-card" :auto-upload="false">
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{ file }">
<img
class="el-upload-list__item-thumbnail"
:src="file.url"
alt=""
/>
<span class="el-upload-list__item-actions">
<span
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
>
<i class="el-icon-zoom-in"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleDownload(file)"
>
<i class="el-icon-download"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleRemove(file)"
>
<i class="el-icon-delete"></i>
</span>
</span>
<div class="flex flex-wrap">
<div
style="width: 148px; height: 148px"
v-for="(url, index) in recordForm.images"
:key="index"
class="mr-6 mb-6 img-div-box"
>
<el-image
style="width: 148px; height: 148px"
:src="url"
fit="contain"
:preview-src-list="[url]"
>
<template #error>
<div
class="w-full flex justify-center items-center"
style="
height: 148px;
border: 1px solid #f0f0f0;
font-style: italic;
color: #ccc;
"
>
图片加载失败
</div>
</template>
</el-image>
<i
class="el-icon-error del-btn-icon"
@click="handleDelImages(index)"
></i>
</div>
</div>
<el-upload
action="#"
list-type="picture-card"
:http-request="handleUpload"
:auto-upload="true"
:before-upload="beforeUpload"
:showFileList="false"
accept=".jpg,.png,.jpeg"
:maxLength="10"
>
<i slot="default" class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="imageDialog">
<img width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
</el-form-item>
<el-form-item label-width="120px" label="备注" prop="remark">
<el-input
@ -996,12 +1039,24 @@ export default {
background-color: #2b8070;
}
}
}
/deep/.el-input__count {
height: 15px;
line-height: 15px;
margin-right: 10px;
margin-bottom: -4px;
.img-div-box {
position: relative;
.del-btn-icon {
display: none;
position: absolute;
top: -8px;
right: -8px;
font-size: 24px;
color: rgba(0, 0, 0, 0.5);
cursor: pointer;
}
&:hover {
.del-btn-icon {
display: block;
}
}
}
}
</style>

Loading…
Cancel
Save