Commit f89e728fa73d9bbaf595c96938710090287dadc7
1 parent
b0ac8d7c
校验报修时间,回显小区
Showing
3 changed files
with
48 additions
and
26 deletions
src/views/event/edit.vue
| 1 | 1 | <script setup lang="ts"> |
| 2 | 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; |
| 3 | -import { eventCategory, handworkEdit } from '@/api/event'; | |
| 3 | +import { eventCategory, handworkEdit } from "@/api/event"; | |
| 4 | 4 | import { useRoute } from "vue-router"; |
| 5 | 5 | import { back } from "@/utils/tool"; |
| 6 | 6 | import type { ElForm } from "element-plus"; |
| ... | ... | @@ -97,16 +97,19 @@ const submitForm = ( |
| 97 | 97 | if (!formEl) return; |
| 98 | 98 | formEl.validate(async (valid) => { |
| 99 | 99 | if (valid) { |
| 100 | - handworkEdit(form.data).then(res => { | |
| 101 | - if(res) { | |
| 102 | - instance?.proxy?.$message.success("操作成功"); | |
| 103 | - back() | |
| 104 | - } | |
| 105 | - }).catch(error => { | |
| 106 | - console.log(error) | |
| 107 | - }).finally (() => { | |
| 108 | - form.loading = false | |
| 109 | - }) | |
| 100 | + handworkEdit(form.data) | |
| 101 | + .then((res) => { | |
| 102 | + if (res) { | |
| 103 | + instance?.proxy?.$message.success("操作成功"); | |
| 104 | + back(); | |
| 105 | + } | |
| 106 | + }) | |
| 107 | + .catch((error) => { | |
| 108 | + console.log(error); | |
| 109 | + }) | |
| 110 | + .finally(() => { | |
| 111 | + form.loading = false; | |
| 112 | + }); | |
| 110 | 113 | } else { |
| 111 | 114 | instance?.proxy?.$message.error("请检查表单格式"); |
| 112 | 115 | form.loading = false; |
| ... | ... | @@ -159,18 +162,14 @@ onMounted(() => { |
| 159 | 162 | </el-date-picker> |
| 160 | 163 | </el-form-item> |
| 161 | 164 | <el-form-item label="活动时长" prop="duration" style="width: 50%"> |
| 162 | - <el-input | |
| 163 | - v-model.trim="form.data.duration" | |
| 164 | - placeholder="请填写活动时长" | |
| 165 | - maxlength="15" | |
| 166 | - /> | |
| 165 | + <el-input v-model.trim="form.data.duration" placeholder="请填写活动时长"> | |
| 166 | + <template #append>小时</template> | |
| 167 | + </el-input> | |
| 167 | 168 | </el-form-item> |
| 168 | 169 | <el-form-item label="活动单价" prop="unitPrice" style="width: 50%"> |
| 169 | - <el-input | |
| 170 | - v-model.trim="form.data.unitPrice" | |
| 171 | - placeholder="请填写活动单价" | |
| 172 | - maxlength="15" | |
| 173 | - /> | |
| 170 | + <el-input v-model.trim="form.data.unitPrice" placeholder="请填写活动单价"> | |
| 171 | + <template #append>元</template> | |
| 172 | + </el-input> | |
| 174 | 173 | </el-form-item> |
| 175 | 174 | <el-form-item label="活动地址" prop="location" style="width: 100%"> |
| 176 | 175 | <el-input | ... | ... |
src/views/event/handwork.vue
| ... | ... | @@ -49,8 +49,8 @@ const getList = async () => { |
| 49 | 49 | data.loading = true; |
| 50 | 50 | try { |
| 51 | 51 | const res = await handworkList(data.params.query); |
| 52 | - data.list = res?.data?.data?.list; | |
| 53 | - data.params.total = res?.data?.data?.total; | |
| 52 | + data.list = res?.data?.data; | |
| 53 | + // data.params.total = res?.data?.data?.total; | |
| 54 | 54 | } catch (e) { |
| 55 | 55 | console.log(e); |
| 56 | 56 | } finally { |
| ... | ... | @@ -143,7 +143,11 @@ onMounted(() => { |
| 143 | 143 | prop="startTime" |
| 144 | 144 | label="开始时间" |
| 145 | 145 | align="center" |
| 146 | - ></el-table-column> | |
| 146 | + > | |
| 147 | + <template #default="scope"> | |
| 148 | + {{ parseTime(new Date(scope.row.startTime).getTime()) }} | |
| 149 | + </template> | |
| 150 | + </el-table-column> | |
| 147 | 151 | <el-table-column |
| 148 | 152 | prop="duration" |
| 149 | 153 | label="活动时长/小时" |
| ... | ... | @@ -177,7 +181,14 @@ onMounted(() => { |
| 177 | 181 | {{statusData.find(u => u.value === scope.row.status)['publish']}} |
| 178 | 182 | </template> |
| 179 | 183 | </el-table-column> |
| 180 | - <el-table-column label="操作" align="center"></el-table-column> | |
| 184 | + <el-table-column label="操作" align="center"> | |
| 185 | + <template #default="scope"> | |
| 186 | + <el-button type="text">编辑</el-button> | |
| 187 | + <el-button type="text">删除</el-button> | |
| 188 | + <el-button type="text">查看人员</el-button> | |
| 189 | + <el-button type="text">编辑/查看/发布活动总结</el-button> | |
| 190 | + </template> | |
| 191 | + </el-table-column> | |
| 181 | 192 | </el-table> |
| 182 | 193 | <Pagination |
| 183 | 194 | :total="data.params.total" | ... | ... |
src/views/repair/edit.vue
| ... | ... | @@ -27,6 +27,16 @@ let form = reactive({ |
| 27 | 27 | }); |
| 28 | 28 | const ruleFormRef = ref<InstanceType<typeof ElForm>>(); |
| 29 | 29 | /** |
| 30 | + * 结束时间要在开始时间之后 | |
| 31 | + */ | |
| 32 | +const checkTime = (rules, value, callback) => { | |
| 33 | + if(new Date(value).getTime() >= new Date(form.data.intentBeginTime).getTime()) { | |
| 34 | + callback() | |
| 35 | + } else { | |
| 36 | + callback(new Error('结束时间要在开始时间之后')) | |
| 37 | + } | |
| 38 | +} | |
| 39 | +/** | |
| 30 | 40 | * 表单验证规则 |
| 31 | 41 | */ |
| 32 | 42 | const rules = reactive({ |
| ... | ... | @@ -75,8 +85,9 @@ const rules = reactive({ |
| 75 | 85 | intentEndTime: [ |
| 76 | 86 | { |
| 77 | 87 | required: true, |
| 78 | - message: "请选择意向上门结束时间", | |
| 88 | + message: "请选择晚于开始时间的意向上门结束时间", | |
| 79 | 89 | trigger: "blur", |
| 90 | + validator: checkTime | |
| 80 | 91 | }, |
| 81 | 92 | ], |
| 82 | 93 | }); |
| ... | ... | @@ -143,6 +154,7 @@ onMounted(() => { |
| 143 | 154 | form.dataType = "add"; |
| 144 | 155 | } else { |
| 145 | 156 | form.dataType = "edit"; |
| 157 | + form.data.neighboorHoodId = ~~useRoute().query.neighboorHoodId; | |
| 146 | 158 | form.checkList = form.data.repairProject |
| 147 | 159 | ? form.data.repairProject?.split(",").map((v) => v / 1) |
| 148 | 160 | : []; | ... | ... |