|
@@ -7,14 +7,12 @@
|
|
|
<view>
|
|
<view>
|
|
|
<view class="form-label-input">
|
|
<view class="form-label-input">
|
|
|
<view class="phone-form-label"><text class="form-label-require">*</text>姓名</view>
|
|
<view class="phone-form-label"><text class="form-label-require">*</text>姓名</view>
|
|
|
- <uni-easyinput v-model="formData.realName"
|
|
|
|
|
- placeholder="请输入姓名" />
|
|
|
|
|
|
|
+ <uni-easyinput v-model="formData.realName" placeholder="请输入姓名" />
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<view class="form-label-input">
|
|
<view class="form-label-input">
|
|
|
<view class="phone-form-label"><text class="form-label-require">*</text>手机号</view>
|
|
<view class="phone-form-label"><text class="form-label-require">*</text>手机号</view>
|
|
|
- <uni-easyinput type="number" v-model="formData.userName"
|
|
|
|
|
- placeholder="请输入手机号" maxlength="11" />
|
|
|
|
|
|
|
+ <uni-easyinput type="number" v-model="formData.userName" placeholder="请输入手机号" maxlength="11" />
|
|
|
</view>
|
|
</view>
|
|
|
<view class="form-label-input">
|
|
<view class="form-label-input">
|
|
|
<view class="phone-form-label">
|
|
<view class="phone-form-label">
|
|
@@ -32,149 +30,254 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<button type="default" class="phone-green-btn info-btn" @click="saveBtn">保存</button>
|
|
<button type="default" class="phone-green-btn info-btn" @click="saveBtn">保存</button>
|
|
|
|
|
+
|
|
|
|
|
+ <commonDialogVue ref="comRefAdd" :content="contentAdd" @confirm-btn="htAdd2"></commonDialogVue>
|
|
|
|
|
+ <commonDialogVue ref="comRefEditor" :content="contentEditor" @confirm-btn="htAdd2"></commonDialogVue>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import {ref,reactive} from "vue";
|
|
|
|
|
-import {onLoad} from "@dcloudio/uni-app";
|
|
|
|
|
-import * as khApi from "@/api/kehu.js"
|
|
|
|
|
-const formData = reactive({
|
|
|
|
|
- realName: '',
|
|
|
|
|
- userName: '',
|
|
|
|
|
- idcard: '',
|
|
|
|
|
- idtype: '1',
|
|
|
|
|
-
|
|
|
|
|
-jutidizhi: '',
|
|
|
|
|
- pageFlag:'add',
|
|
|
|
|
- id:null,
|
|
|
|
|
- userId:null,
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-// 返回
|
|
|
|
|
-function goUpPage() {
|
|
|
|
|
- uni.redirectTo({
|
|
|
|
|
- url: '/pages/admin/kehu/kehuList'
|
|
|
|
|
|
|
+ import {
|
|
|
|
|
+ ref,
|
|
|
|
|
+ reactive
|
|
|
|
|
+ } from "vue";
|
|
|
|
|
+ import {
|
|
|
|
|
+ onLoad
|
|
|
|
|
+ } from "@dcloudio/uni-app";
|
|
|
|
|
+ import * as khApi from "@/api/kehu.js"
|
|
|
|
|
+ const formData = reactive({
|
|
|
|
|
+ realName: '',
|
|
|
|
|
+ userName: '',
|
|
|
|
|
+ idcard: '',
|
|
|
|
|
+ idtype: '1',
|
|
|
|
|
+
|
|
|
|
|
+ jutidizhi: '',
|
|
|
|
|
+ pageFlag: 'add',
|
|
|
|
|
+ id: null,
|
|
|
|
|
+ userId: null,
|
|
|
})
|
|
})
|
|
|
-}
|
|
|
|
|
-function idCardChange(data) {
|
|
|
|
|
- formData.idtype = formData.idtype == 1 ? 2 : 1;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 保存
|
|
|
|
|
-function saveBtn(){
|
|
|
|
|
- if(formData.pageFlag==='editor'){
|
|
|
|
|
- htEditor();
|
|
|
|
|
- }else{
|
|
|
|
|
- htAdd();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const contentAdd = ref('');
|
|
|
|
|
+ const contentEditor = ref('');
|
|
|
|
|
+
|
|
|
|
|
+ const comRefAdd = ref(null);
|
|
|
|
|
+ const comRefEditor = ref(null)
|
|
|
|
|
+
|
|
|
|
|
+ // 返回
|
|
|
|
|
+ function goUpPage() {
|
|
|
|
|
+ uni.redirectTo({
|
|
|
|
|
+ url: '/pages/admin/kehu/kehuList'
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 新增
|
|
|
|
|
-function htAdd(){
|
|
|
|
|
-
|
|
|
|
|
- let arr = [];
|
|
|
|
|
- if (!formData.realName) {
|
|
|
|
|
- arr.push('姓名');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function idCardChange(data) {
|
|
|
|
|
+ formData.idtype = formData.idtype == 1 ? 2 : 1;
|
|
|
}
|
|
}
|
|
|
- if (!formData.userName) {
|
|
|
|
|
- arr.push('电话');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 保存
|
|
|
|
|
+ function saveBtn() {
|
|
|
|
|
+ if (formData.pageFlag === 'editor') {
|
|
|
|
|
+ htEditor();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ htAdd();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (!formData.realName || !formData.userName) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
- title: `请完善${arr.join('、')}信息!`
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 新增
|
|
|
|
|
+ function htAdd() {
|
|
|
|
|
+
|
|
|
|
|
+ let arr = [];
|
|
|
|
|
+ if (!formData.realName) {
|
|
|
|
|
+ arr.push('姓名');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.userName) {
|
|
|
|
|
+ arr.push('电话');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.realName || !formData.userName) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ title: `请完善${arr.join('、')}信息!`
|
|
|
|
|
+ })
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '新增中...',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ const opt = {
|
|
|
|
|
+ realName: formData.realName,
|
|
|
|
|
+ userName: formData.userName,
|
|
|
|
|
+ idtype: formData.idtype,
|
|
|
|
|
+ idcard: formData.idcard,
|
|
|
|
|
+ jutidizhi: formData.jutidizhi,
|
|
|
|
|
+ checked: 0
|
|
|
|
|
+ }
|
|
|
|
|
+ khApi.getKehuAdd(opt).then(res => {
|
|
|
|
|
+ if (res.data.result) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '新增成功'
|
|
|
|
|
+ })
|
|
|
|
|
+ goUpPage();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ contentAdd.value = res.data.message;
|
|
|
|
|
+ comRefAdd.value.handleShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
})
|
|
})
|
|
|
- return;
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- uni.showLoading({
|
|
|
|
|
- title: '新增中...',
|
|
|
|
|
- mask: true
|
|
|
|
|
- });
|
|
|
|
|
- const opt = {
|
|
|
|
|
- realName: formData.realName,
|
|
|
|
|
- userName: formData.userName,
|
|
|
|
|
- idtype: formData.idtype,
|
|
|
|
|
- idcard: formData.idcard,
|
|
|
|
|
- jutidizhi: formData.jutidizhi,
|
|
|
|
|
- }
|
|
|
|
|
- khApi.getKehuAdd(opt).then(res => {
|
|
|
|
|
- if (res.data) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function htAdd2() {
|
|
|
|
|
+
|
|
|
|
|
+ let arr = [];
|
|
|
|
|
+ if (!formData.realName) {
|
|
|
|
|
+ arr.push('姓名');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.userName) {
|
|
|
|
|
+ arr.push('电话');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.realName || !formData.userName) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '新增成功'
|
|
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ title: `请完善${arr.join('、')}信息!`
|
|
|
})
|
|
})
|
|
|
- goUpPage();
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- }).finally(()=>{
|
|
|
|
|
- uni.hideLoading()
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 编辑
|
|
|
|
|
-function handleEditor() {
|
|
|
|
|
- khApi.getKehuInfo({
|
|
|
|
|
- userId: formData.userId,
|
|
|
|
|
- id:formData.id,
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- formData.realName = res.data.realName,
|
|
|
|
|
- formData.userName = res.data.userName,
|
|
|
|
|
- formData.idcard = res.data.idcard;
|
|
|
|
|
- formData.idtype = res.data.idtype;
|
|
|
|
|
- formData.addres = res.data.addres;
|
|
|
|
|
- formData.jutidizhi = res.data.jutidizhi;
|
|
|
|
|
- formData.idtype = res.data.idtype;
|
|
|
|
|
-
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-function htEditor(){
|
|
|
|
|
- let arr = [];
|
|
|
|
|
- if (!formData.realName) {
|
|
|
|
|
- arr.push('姓名');
|
|
|
|
|
- }
|
|
|
|
|
- if (!formData.userName) {
|
|
|
|
|
- arr.push('电话');
|
|
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '新增中...',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ const opt = {
|
|
|
|
|
+ realName: formData.realName,
|
|
|
|
|
+ userName: formData.userName,
|
|
|
|
|
+ idtype: formData.idtype,
|
|
|
|
|
+ idcard: formData.idcard,
|
|
|
|
|
+ jutidizhi: formData.jutidizhi,
|
|
|
|
|
+ checked:1
|
|
|
|
|
+ }
|
|
|
|
|
+ khApi.getKehuAdd(opt).then(res => {
|
|
|
|
|
+ if (res.data) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '新增成功'
|
|
|
|
|
+ })
|
|
|
|
|
+ goUpPage();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- if (!formData.realName || !formData.userName) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
- title: `请完善${arr.join('、')}信息!`
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 编辑
|
|
|
|
|
+ function handleEditor() {
|
|
|
|
|
+ khApi.getKehuInfo({
|
|
|
|
|
+ userId: formData.userId,
|
|
|
|
|
+ id: formData.id,
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ formData.realName = res.data.realName,
|
|
|
|
|
+ formData.userName = res.data.userName,
|
|
|
|
|
+ formData.idcard = res.data.idcard;
|
|
|
|
|
+ formData.idtype = res.data.idtype;
|
|
|
|
|
+ formData.addres = res.data.addres;
|
|
|
|
|
+ formData.jutidizhi = res.data.jutidizhi;
|
|
|
|
|
+ formData.idtype = res.data.idtype;
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
- return;
|
|
|
|
|
}
|
|
}
|
|
|
- uni.showLoading({
|
|
|
|
|
- title: '更新中...',
|
|
|
|
|
- mask: true
|
|
|
|
|
- });
|
|
|
|
|
- const opt = {
|
|
|
|
|
- userId: formData.userId,
|
|
|
|
|
- realName: formData.realName,
|
|
|
|
|
- userName: formData.userName,
|
|
|
|
|
- idtype: formData.idtype,
|
|
|
|
|
- idcard: formData.idcard,
|
|
|
|
|
- jutidizhi: formData.jutidizhi,
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function htEditor() {
|
|
|
|
|
+ let arr = [];
|
|
|
|
|
+ if (!formData.realName) {
|
|
|
|
|
+ arr.push('姓名');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.userName) {
|
|
|
|
|
+ arr.push('电话');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.realName || !formData.userName) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ title: `请完善${arr.join('、')}信息!`
|
|
|
|
|
+ })
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '更新中...',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ const opt = {
|
|
|
|
|
+ userId: formData.userId,
|
|
|
|
|
+ realName: formData.realName,
|
|
|
|
|
+ userName: formData.userName,
|
|
|
|
|
+ idtype: formData.idtype,
|
|
|
|
|
+ idcard: formData.idcard,
|
|
|
|
|
+ jutidizhi: formData.jutidizhi,
|
|
|
|
|
+ checked: 0
|
|
|
|
|
+ }
|
|
|
|
|
+ khApi.getKehuUpdate(opt).then(res => {
|
|
|
|
|
+ if (res.data.result) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '编辑成功'
|
|
|
|
|
+ })
|
|
|
|
|
+ goUpPage();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ contentEditor.value = res.data.message;
|
|
|
|
|
+ comRefEditor.value.handleShow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- khApi.getKehuUpdate(opt).then(res => {
|
|
|
|
|
- if (res.data) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function htEditor2() {
|
|
|
|
|
+ let arr = [];
|
|
|
|
|
+ if (!formData.realName) {
|
|
|
|
|
+ arr.push('姓名');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.userName) {
|
|
|
|
|
+ arr.push('电话');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!formData.realName || !formData.userName) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '编辑成功'
|
|
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ title: `请完善${arr.join('、')}信息!`
|
|
|
})
|
|
})
|
|
|
- goUpPage();
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- }).finally(()=>{
|
|
|
|
|
- uni.hideLoading()
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-onLoad((options) => {
|
|
|
|
|
- if(options.id && options.userId){
|
|
|
|
|
- formData.pageFlag = 'editor';
|
|
|
|
|
- formData.id = options.id;
|
|
|
|
|
- formData.userId = options.userId;
|
|
|
|
|
- handleEditor();
|
|
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '更新中...',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ const opt = {
|
|
|
|
|
+ userId: formData.userId,
|
|
|
|
|
+ realName: formData.realName,
|
|
|
|
|
+ userName: formData.userName,
|
|
|
|
|
+ idtype: formData.idtype,
|
|
|
|
|
+ idcard: formData.idcard,
|
|
|
|
|
+ jutidizhi: formData.jutidizhi,
|
|
|
|
|
+ checked: 1
|
|
|
|
|
+ }
|
|
|
|
|
+ khApi.getKehuUpdate(opt).then(res => {
|
|
|
|
|
+ if (res.data) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '编辑成功'
|
|
|
|
|
+ })
|
|
|
|
|
+ goUpPage();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
-})
|
|
|
|
|
|
|
+
|
|
|
|
|
+ onLoad((options) => {
|
|
|
|
|
+ if (options.id && options.userId) {
|
|
|
|
|
+ formData.pageFlag = 'editor';
|
|
|
|
|
+ formData.id = options.id;
|
|
|
|
|
+ formData.userId = options.userId;
|
|
|
|
|
+ handleEditor();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
<style>
|