Commit a561a5a8195629441ff876d1ff09209828716a50
1 parent
cc9fdf14
报修订单加图片
Showing
2 changed files
with
53 additions
and
13 deletions
src/components/Photowall/index.vue
| ... | ... | @@ -67,7 +67,7 @@ const uploadSettings = reactive({ |
| 67 | 67 | * @param {UploadFile} file 文件对象 |
| 68 | 68 | */ |
| 69 | 69 | const handlePictureCardPreview = (file: UploadFile) => { |
| 70 | - dialogImageUrl.value = file?.response?.data; | |
| 70 | + dialogImageUrl.value = file?.url; | |
| 71 | 71 | dialogVisible.value = true; |
| 72 | 72 | }; |
| 73 | 73 | /** | ... | ... |
src/views/repair/edit.vue
| ... | ... | @@ -2,11 +2,11 @@ |
| 2 | 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; |
| 3 | 3 | import { useRoute } from "vue-router"; |
| 4 | 4 | import { getTableList } from "@/api/community/residence"; |
| 5 | -import { getTableList as getProject } from '@/api/notify/maintain'; | |
| 5 | +import { getTableList as getProject } from "@/api/notify/maintain"; | |
| 6 | 6 | import { repairAdd, repairDetail } from "@/api/notify/repair"; |
| 7 | 7 | import { back } from "@/utils/tool"; |
| 8 | -// import * as store from "@/pinia/index"; | |
| 9 | -import { useLoginStore } from '@/pinia/login'; | |
| 8 | +import Photowall from "@/components/Photowall/index.vue"; | |
| 9 | +import { useLoginStore } from "@/pinia/login"; | |
| 10 | 10 | import type { ElForm } from "element-plus"; |
| 11 | 11 | let instance: ComponentInternalInstance | null = getCurrentInstance(); |
| 12 | 12 | let form = reactive({ |
| ... | ... | @@ -20,7 +20,9 @@ let form = reactive({ |
| 20 | 20 | intentEndTime: "", |
| 21 | 21 | remark: "", |
| 22 | 22 | id: null, |
| 23 | + img: "", | |
| 23 | 24 | }, |
| 25 | + publicityPic: [], | |
| 24 | 26 | neighborhoods: [], |
| 25 | 27 | projects: [], |
| 26 | 28 | loading: false, |
| ... | ... | @@ -31,12 +33,14 @@ const ruleFormRef = ref<InstanceType<typeof ElForm>>(); |
| 31 | 33 | * 结束时间要在开始时间之后 |
| 32 | 34 | */ |
| 33 | 35 | const checkTime = (rules, value, callback) => { |
| 34 | - if(new Date(value).getTime() >= new Date(form.data.intentBeginTime).getTime()) { | |
| 35 | - callback() | |
| 36 | + if ( | |
| 37 | + new Date(value).getTime() >= new Date(form.data.intentBeginTime).getTime() | |
| 38 | + ) { | |
| 39 | + callback(); | |
| 36 | 40 | } else { |
| 37 | - callback(new Error('结束时间要在开始时间之后')) | |
| 41 | + callback(new Error("结束时间要在开始时间之后")); | |
| 38 | 42 | } |
| 39 | -} | |
| 43 | +}; | |
| 40 | 44 | /** |
| 41 | 45 | * 表单验证规则 |
| 42 | 46 | */ |
| ... | ... | @@ -88,7 +92,7 @@ const rules = reactive({ |
| 88 | 92 | required: true, |
| 89 | 93 | message: "请选择晚于开始时间的意向上门结束时间", |
| 90 | 94 | trigger: "blur", |
| 91 | - validator: checkTime | |
| 95 | + validator: checkTime, | |
| 92 | 96 | }, |
| 93 | 97 | ], |
| 94 | 98 | }); |
| ... | ... | @@ -97,6 +101,7 @@ const rules = reactive({ |
| 97 | 101 | */ |
| 98 | 102 | const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 99 | 103 | if (!formEl) return; |
| 104 | + form.publicityPic = []; | |
| 100 | 105 | formEl.resetFields(); |
| 101 | 106 | }; |
| 102 | 107 | /** |
| ... | ... | @@ -105,9 +110,9 @@ const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 105 | 110 | const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 106 | 111 | form.loading = true; |
| 107 | 112 | if (!formEl) return; |
| 113 | + form.data.img = form.publicityPic.map((item) => item.url).join(","); | |
| 108 | 114 | formEl.validate((valid) => { |
| 109 | 115 | if (valid) { |
| 110 | - console.log(form.data); | |
| 111 | 116 | repairAdd(form.data) |
| 112 | 117 | .then((res) => { |
| 113 | 118 | if (res) { |
| ... | ... | @@ -156,7 +161,6 @@ const getProjects = async (pageSize: number = 20) => { |
| 156 | 161 | const res = await getProject({ |
| 157 | 162 | page: 1, |
| 158 | 163 | pageSize: pageSize, |
| 159 | - // oid:store?.family?.loginStore()?.organizationId??0 | |
| 160 | 164 | oid: useLoginStore()?.getOid ?? 0, |
| 161 | 165 | }); |
| 162 | 166 | form.projects = res?.data?.data?.list; |
| ... | ... | @@ -166,7 +170,22 @@ const getProjects = async (pageSize: number = 20) => { |
| 166 | 170 | } catch (e) { |
| 167 | 171 | console.log(e); |
| 168 | 172 | } |
| 169 | -} | |
| 173 | +}; | |
| 174 | +/** | |
| 175 | + * 多图上传组件回调 | |
| 176 | + * @param {string} images 回调的图片urls | |
| 177 | + * @param {string} tagName 标签 | |
| 178 | + */ | |
| 179 | +const handleFinish = (images) => { | |
| 180 | + form.publicityPic = []; | |
| 181 | + setTimeout(() => { | |
| 182 | + images.map((item) => { | |
| 183 | + form.publicityPic.push({ | |
| 184 | + url: item, | |
| 185 | + }); | |
| 186 | + }); | |
| 187 | + }, 500); | |
| 188 | +}; | |
| 170 | 189 | onMounted(() => { |
| 171 | 190 | getNeighborhoods(); |
| 172 | 191 | getProjects(); |
| ... | ... | @@ -177,6 +196,15 @@ onMounted(() => { |
| 177 | 196 | form.dataType = "edit"; |
| 178 | 197 | form.data.neighboorHoodId = ~~useRoute().query.neighboorHoodId; |
| 179 | 198 | form.data.repairProject = ~~useRoute().query.repairProject; |
| 199 | + if (useRoute().query.img) { | |
| 200 | + useRoute() | |
| 201 | + .query.img.split(",") | |
| 202 | + .map((item) => { | |
| 203 | + form.publicityPic.push({ | |
| 204 | + url: item, | |
| 205 | + }); | |
| 206 | + }); | |
| 207 | + } | |
| 180 | 208 | } |
| 181 | 209 | }); |
| 182 | 210 | </script> |
| ... | ... | @@ -235,7 +263,10 @@ onMounted(() => { |
| 235 | 263 | </el-form-item> |
| 236 | 264 | <el-form-item label="报修项目" prop="repairProject" style="width: 100%"> |
| 237 | 265 | <!-- 启用状态的报修项目可选 --> |
| 238 | - <el-select v-model="form.data.repairProject" placeholder="请选择报修项目"> | |
| 266 | + <el-select | |
| 267 | + v-model="form.data.repairProject" | |
| 268 | + placeholder="请选择报修项目" | |
| 269 | + > | |
| 239 | 270 | <el-option |
| 240 | 271 | v-for="(item, index) in form.projects" |
| 241 | 272 | :key="index" |
| ... | ... | @@ -270,6 +301,15 @@ onMounted(() => { |
| 270 | 301 | placeholder="请选择意向上门结束时间" |
| 271 | 302 | ></el-date-picker> |
| 272 | 303 | </el-form-item> |
| 304 | + <el-form-item label="报修图片" prop="img" style="width: 100%"> | |
| 305 | + <Photowall | |
| 306 | + @finish="handleFinish" | |
| 307 | + moduleName="repair" | |
| 308 | + :limit="3" | |
| 309 | + tip="最多可以上传3张图片,单张图片大小不可超过1MB" | |
| 310 | + :fileList="form.publicityPic" | |
| 311 | + ></Photowall> | |
| 312 | + </el-form-item> | |
| 273 | 313 | <el-form-item label="备注" prop="remark" style="width: 100%"> |
| 274 | 314 | <el-input |
| 275 | 315 | v-model.trim="form.data.remark" | ... | ... |