| | |
| | | @cancel="isShowTypePicker = false" @confirm="confirmType()" keyName="dictValue"></u-picker> |
| | | <u-picker :show="isShowLabelPicker" :columns="labelList" :defaultIndex="labelIndex" |
| | | @cancel="isShowLabelPicker = false" @confirm="confirmLabelType()" keyName="name"></u-picker> |
| | | <footer-btn @click="submitInfo" /> |
| | | <footer-btn @click="submitInfo" :text="isEdit?'保存':'提交'" /> |
| | | |
| | | <u-popup :show="isShowPopup" mode="bottom" :round="10" closeable="true" @close="isShowPopup = false"> |
| | | <view class="popup-content"> |
| | |
| | | |
| | | <script> |
| | | import { |
| | | addWorkLog |
| | | addWorkLog, |
| | | getWorkLogDetail, |
| | | updateWorkLog |
| | | } from "@/api/workLog/workLog.js" |
| | | import uploadMixin from "@/mixin/uploadMixin"; |
| | | import { |
| | | bizDictionary |
| | | bizDictionary, |
| | | update |
| | | } from '@/api/system/dict.js' |
| | | import { |
| | | getLabelListByParentId |
| | |
| | | import { |
| | | fetchHousehold |
| | | } from "@/api/house/household.js" |
| | | import { |
| | | getHouseholdDetail |
| | | } from '@/api/house/household.js' |
| | | export default { |
| | | mixins: [uploadMixin], |
| | | data() { |
| | |
| | | images: [] |
| | | }, |
| | | info: { |
| | | name: "", |
| | | phone: "", |
| | | // name: "", |
| | | // phone: "", |
| | | context: "" |
| | | }, |
| | | rules: { |
| | |
| | | houseHoldList: [], |
| | | selectedHousehold: {}, |
| | | isShowPopup: false, |
| | | address: "" |
| | | address: "", |
| | | isEdit: false, |
| | | id: "" |
| | | } |
| | | }, |
| | | // onLoad() { |
| | |
| | | // }, |
| | | |
| | | |
| | | onLoad() { |
| | | this.getTypeList(); |
| | | this.getLabelLit(); |
| | | async onLoad(option) { |
| | | await this.getTypeList(); |
| | | await this.getLabelLit(); |
| | | if (option.id) { |
| | | this.isEdit = true; |
| | | this.id = option.id; |
| | | this.getDetail(option.id) |
| | | } |
| | | }, |
| | | |
| | | |
| | | methods: { |
| | | |
| | | |
| | | getDetail(id) { |
| | | getWorkLogDetail({ |
| | | id |
| | | }).then(res => { |
| | | console.log(res); |
| | | if (res.code == 200) { |
| | | let data = res.data |
| | | this.typeIndex = this.getTypeValue(data.type).index; |
| | | this.typeName = this.getTypeValue(data.type).name; |
| | | this.workTime = Number(new Date(data.workTime)) |
| | | this.info.type = data.type; |
| | | this.info.workTime = data.workTime; |
| | | this.info.context = data.context; |
| | | this.info.householdId = data.householdId; |
| | | this.info.personType = data.personType; |
| | | this.labelIndex = this.getLabelValue(data.personType).index; |
| | | this.labelName = this.getLabelValue(data.personType).name; |
| | | this.getHouseholdList(); |
| | | this.getHousehold(data.householdId); |
| | | this.form.images = this.$setImageUrl(data.url, 2); |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | getTypeValue(value) { |
| | | for (let i = 0, ii = this.typeList[0].length; i < ii; i++) { |
| | | if (value == this.typeList[0][i].dictKey) { |
| | | return { |
| | | index: [i], |
| | | name: this.typeList[0][i].dictValue |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | |
| | | getLabelValue(value) { |
| | | for (let i = 0, ii = this.labelList[0].length; i < ii; i++) { |
| | | if (value == this.labelList[0][i].id) { |
| | | return { |
| | | index: [i], |
| | | name: this.labelList[0][i].name |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | |
| | | getTypeList() { |
| | | bizDictionary({ |
| | |
| | | parentId: 100 |
| | | }).then(res => { |
| | | this.labelList = [res.data]; |
| | | }) |
| | | }, |
| | | |
| | | getHousehold(id) { |
| | | getHouseholdDetail({ |
| | | id |
| | | }).then(res => { |
| | | console.log(res); |
| | | this.address = res.data.currentAddress; |
| | | this.selectedHousehold = res.data; |
| | | }) |
| | | }, |
| | | |
| | |
| | | submitInfo() { |
| | | this.$refs.form.validate().then(valid => { |
| | | this.checkImages(); |
| | | addWorkLog(this.info).then(res => { |
| | | uni.showToast({ |
| | | icon: 'success', |
| | | title: '提交成功', |
| | | success() { |
| | | setTimeout(() => { |
| | | uni.navigateBack() |
| | | }, 1000) |
| | | } |
| | | }) |
| | | this.info.status = 2; |
| | | if (this.isEdit) { |
| | | this.updateWorkLogRequest() |
| | | } else { |
| | | this.addWorkLogRequest() |
| | | } |
| | | |
| | | }) |
| | | }, |
| | | |
| | | addWorkLogRequest() { |
| | | addWorkLog(this.info).then(res => { |
| | | uni.showToast({ |
| | | icon: 'success', |
| | | title: '提交成功', |
| | | success() { |
| | | setTimeout(() => { |
| | | uni.navigateBack() |
| | | }, 1000) |
| | | } |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | updateWorkLogRequest() { |
| | | updateWorkLog(this.info).then(res => { |
| | | uni.showToast({ |
| | | icon: 'success', |
| | | title: '提交成功', |
| | | success() { |
| | | setTimeout(() => { |
| | | uni.navigateBack() |
| | | }, 1000) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |