Browse Source

上传图片

fenbao
wangyx 1 month ago
parent
commit
f898c4a046
  1. 152
      pagesA/checkout/detail/detail.vue
  2. 109
      pagesA/force/index/index.vue
  3. 113
      pagesA/release/detail/detail.vue
  4. 383
      pagesA/xjPage/xj.vue

152
pagesA/checkout/detail/detail.vue

@ -18,7 +18,8 @@
>{{ info.gender == 1 ? "男" : "女" }}</view >{{ info.gender == 1 ? "男" : "女" }}</view
> >
<view class="info-row" <view class="info-row"
><text class="label">联系电话</text>{{ maskPhoneNumber(info.telephone) }}</view ><text class="label">联系电话</text
>{{ maskPhoneNumber(info.telephone) }}</view
> >
<view class="info-row" <view class="info-row"
><text class="label">居住日期</text>{{ info.checkInDate }}{{ ><text class="label">居住日期</text>{{ info.checkInDate }}{{
@ -91,18 +92,36 @@
<view class="section-card"> <view class="section-card">
<view class="section-title">图片/视频</view> <view class="section-title">图片/视频</view>
<u-upload <u-upload
<<<<<<< Updated upstream
<<<<<<< Updated upstream
<<<<<<< Updated upstream
accept="media" accept="media"
=======
=======
>>>>>>> Stashed changes
=======
>>>>>>> Stashed changes
:max-count="10"
:multiple="true"
:preview-full-image="true"
:deletable="true"
:show-upload-list="true"
<<<<<<< Updated upstream
<<<<<<< Updated upstream
>>>>>>> Stashed changes
=======
>>>>>>> Stashed changes
=======
>>>>>>> Stashed changes
:fileList="fileList" :fileList="fileList"
@afterRead="afterRead" :auto-upload="false"
@delete="deletePic" accept="all"
multiple
:maxCount="10"
uploadIconColor="#12c3c3"
:previewImage="true"
:maxSize="10 * 1024 * 1024" :maxSize="10 * 1024 * 1024"
@oversize="oversize" @oversize="oversize"
@delete="onDelete"
:disabled="true"
> >
<view class="custom-upload-btn"> <view class="custom-upload-btn" @click.stop="chooseImage">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
@ -110,8 +129,7 @@
mode="aspectFill" mode="aspectFill"
></image> ></image>
</view> </view>
<view class="upload-tips">点击上传</view>
<view class="upload-tips">最多10个</view>
</view> </view>
</u-upload> </u-upload>
</view> </view>
@ -178,7 +196,7 @@ export default {
if (!phoneNumber || phoneNumber.length !== 11) { if (!phoneNumber || phoneNumber.length !== 11) {
return phoneNumber; return phoneNumber;
} }
return phoneNumber.substr(0, 3) + '****' + phoneNumber.substr(7); return phoneNumber.substr(0, 3) + "****" + phoneNumber.substr(7);
}, },
getFacilities(id) { getFacilities(id) {
getRoomFacilities({ houseId: id }).then((res) => { getRoomFacilities({ houseId: id }).then((res) => {
@ -193,66 +211,55 @@ export default {
beforeRead(event) { beforeRead(event) {
console.log("event", event); console.log("event", event);
}, },
// chooseImage() {
oversize(e) { uni.chooseImage({
this.$u.toast("请传10MB以内大小的图片/视频!"); count: 10 - this.fileList.length,
return false; sizeType: ["original", "compressed"],
}, sourceType: ["album", "camera"],
success: async (res) => {
// uni.showLoading({ title: "上传中...", mask: true });
async afterRead(event) {
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
try { try {
const result = await uploadImage(lists[i].url); const files =
let item = this[`fileList${event.name}`][fileListLen]; res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
this[`fileList${event.name}`].splice( for (let i = 0; i < files.length; i++) {
fileListLen, const filePath = files[i].path;
1, const uploadRes = await uploadImage(filePath);
Object.assign(item, { this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image",
status: "success", status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
} catch (err) {
//
let msg = (err && err.msg) || (err && err.message) || "上传失败";
console.log('344',err);
uni.showToast({
title: msg,
icon: "none",
duration: 3000
}); });
//
this[`fileList${event.name}`].splice(fileListLen, 1);
return; //
} }
this.img1 = this.fileList.map((v) => v.url);
} catch (e) {
uni.showToast({ title: "上传失败", icon: "none" });
} finally {
uni.hideLoading();
} }
var arry = []; },
this.fileList.filter((v, i) => { fail: () => {
arry.push(v.url); uni.hideLoading();
},
}); });
this.img1 = arry; },
//
oversize(e) {
this.$u.toast("请传10MB以内大小的图片/视频!");
return false;
}, },
// //
deletePic(event) { onDelete(event) {
this[`fileList${event.name}`].splice(event.index, 1); this[`fileList${event.name}`].splice(event.index, 1);
var arry = []; var arry = [];
this.fileList.filter((v, i) => { this.fileList.filter((v, i) => {
arry.push(v.url); arry.push({
name: v.name || "",
format: v.type,
url: v.url,
});
}); });
this.img1 = arry; this.form.imageList = arry;
}, },
// //
handleTempSave(formData) { handleTempSave(formData) {
@ -270,33 +277,36 @@ export default {
onSubmit() { onSubmit() {
// //
const uncheckedDevices = this.deviceList.filter((item, index) => { const uncheckedDevices = this.deviceList.filter((item, index) => {
return this.checkStatus[index] === undefined || this.checkStatus[index] === ''; return (
this.checkStatus[index] === undefined ||
this.checkStatus[index] === ""
);
}); });
if (uncheckedDevices.length > 0) { if (uncheckedDevices.length > 0) {
uni.showToast({ uni.showToast({
title: '请完成所有设备检查', title: "请完成所有设备检查",
icon: 'none', icon: "none",
duration: 2000 duration: 2000,
}); });
return; return;
} }
// //
if (!this.waterMeterValue || this.waterMeterValue.trim() === '') { if (!this.waterMeterValue || this.waterMeterValue.trim() === "") {
uni.showToast({ uni.showToast({
title: '请输入水表数', title: "请输入水表数",
icon: 'none', icon: "none",
duration: 2000 duration: 2000,
}); });
return; return;
} }
if (!this.energyMeterValue || this.energyMeterValue.trim() === '') { if (!this.energyMeterValue || this.energyMeterValue.trim() === "") {
uni.showToast({ uni.showToast({
title: '请输入电表数', title: "请输入电表数",
icon: 'none', icon: "none",
duration: 2000 duration: 2000,
}); });
return; return;
} }

109
pagesA/force/index/index.vue

@ -97,27 +97,27 @@
></u-textarea> ></u-textarea>
<view class="label-des">上传图片/视频</view> <view class="label-des">上传图片/视频</view>
<u-upload <u-upload
accept="all" :max-count="10"
:multiple="true"
:preview-full-image="true"
:deletable="true"
:show-upload-list="true"
:fileList="fileList" :fileList="fileList"
@afterRead="afterRead" :auto-upload="false"
@delete="deletePic" accept="all"
multiple
:maxCount="10"
uploadIconColor="#12c3c3"
:previewImage="true"
:maxSize="10 * 1024 * 1024" :maxSize="10 * 1024 * 1024"
@oversize="oversize" @oversize="oversize"
@delete="onDelete"
:disabled="true"
> >
<view class="custom-upload-btn"> <view class="custom-upload-btn" @click.stop="chooseImage">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
src="/static/img/camera-icon.png" src="/static/img/camera-icon.png"
mode="aspectFill" mode="aspectFill"
> ></image>
</image>
</view> </view>
<view class="upload-tips">点击上传</view> <view class="upload-tips">点击上传</view>
</view> </view>
</u-upload> </u-upload>
@ -230,64 +230,45 @@ export default {
(this.baseInfo.unitName = ""), (this.baseInfo.unitName = ""),
(this.baseInfo.roomTypeName = ""); (this.baseInfo.roomTypeName = "");
}, },
// chooseImage() {
oversize(e) { uni.chooseImage({
this.$u.toast("请传10MB以内大小的图片/视频!"); count: 10 - this.fileList.length,
return false; sizeType: ["original", "compressed"],
}, sourceType: ["album", "camera"],
// success: async (res) => {
beforeRead(event) { uni.showLoading({ title: "上传中...", mask: true });
// try {
const { file } = event; const files =
if (file.size > 10 * 1024 * 1024) { res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
// 10MB for (let i = 0; i < files.length; i++) {
uni.showToast({ const filePath = files[i].path;
title: "文件过大", const uploadRes = await uploadImage(filePath);
icon: "none", this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image",
status: "success",
}); });
return false;
} }
return true; this.img1 = this.fileList.map((v) => v.url);
}, } catch (e) {
uni.showToast({ title: "上传失败", icon: "none" });
// } finally {
async afterRead(event) { uni.hideLoading();
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadImage(lists[i].url);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
} }
var arry = []; },
this.fileList.filter((v, i) => { fail: () => {
arry.push({ uni.hideLoading();
name: v.name || "", },
format: v.type,
url: v.url,
});
}); });
// this.img1 = arry; },
//
oversize(e) {
this.$u.toast("请传10MB以内大小的图片/视频!");
return false;
}, },
// //
deletePic(event) { onDelete(event) {
this[`fileList${event.name}`].splice(event.index, 1); this[`fileList${event.name}`].splice(event.index, 1);
var arry = []; var arry = [];
this.fileList.filter((v, i) => { this.fileList.filter((v, i) => {
@ -297,7 +278,7 @@ export default {
url: v.url, url: v.url,
}); });
}); });
// this.img1 = arry; this.form.imageList = arry;
}, },
onProblemTypeConfirm(e) { onProblemTypeConfirm(e) {
const selectedItem = e.value[0]; const selectedItem = e.value[0];

113
pagesA/release/detail/detail.vue

@ -72,36 +72,21 @@
<!-- 图片/视频上传区域 --> <!-- 图片/视频上传区域 -->
<view class="section-card"> <view class="section-card">
<view class="section-title">图片/视频</view> <view class="section-title">图片/视频</view>
<!-- #ifdef MP-WEIXIN -->
<u-upload <u-upload
:max-count="10"
:multiple="true"
:preview-full-image="true"
:deletable="true"
:show-upload-list="true"
:fileList="fileList" :fileList="fileList"
@afterRead="afterRead" :auto-upload="false"
@delete="deletePic"
multiple
:maxCount="10"
uploadIconColor="#12c3c3"
uploadText="点击上传"
:previewImage="true"
accept="all" accept="all"
:maxSize="10 * 1024 * 1024" :maxSize="10 * 1024 * 1024"
@oversize="oversize" @oversize="oversize"
@delete="onDelete"
:disabled="true"
> >
</u-upload> <view class="custom-upload-btn" @click.stop="chooseImage">
<!-- #endif -->
<!-- #ifdef H5 -->
<u-upload
:fileList="fileList"
@afterRead="afterRead"
@delete="deletePic"
multiple
:maxCount="10"
uploadIconColor="#12c3c3"
:previewImage="true"
accept="image/*,video/*"
:maxSize="10 * 1024 * 1024"
@oversize="oversize"
>
<view class="custom-upload-btn">
<view class="icon-box"> <view class="icon-box">
<image <image
class="camera-icon" class="camera-icon"
@ -109,11 +94,9 @@
mode="aspectFill" mode="aspectFill"
></image> ></image>
</view> </view>
<view class="upload-tips">点击上传</view> <view class="upload-tips">点击上传</view>
</view> </view>
</u-upload> </u-upload>
<!-- #endif -->
</view> </view>
<!-- 提交按钮 --> <!-- 提交按钮 -->
<view class="submit-btn-wrap"> <view class="submit-btn-wrap">
@ -185,53 +168,55 @@ export default {
} }
}, },
methods: { methods: {
// chooseImage() {
deletePic(event) { uni.chooseImage({
this[`fileList${event.name}`].splice(event.index, 1); count: 10 - this.fileList.length,
var arry = []; sizeType: ["original", "compressed"],
this.fileList.filter((v, i) => { sourceType: ["album", "camera"],
arry.push(v.url); success: async (res) => {
uni.showLoading({ title: "上传中...", mask: true });
try {
const files =
res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
for (let i = 0; i < files.length; i++) {
const filePath = files[i].path;
const uploadRes = await uploadImage(filePath);
this.fileList.push({
url: uploadRes.data?.url || uploadRes.url || uploadRes.path,
name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image",
status: "success",
});
}
this.img1 = this.fileList.map((v) => v.url);
} catch (e) {
uni.showToast({ title: "上传失败", icon: "none" });
} finally {
uni.hideLoading();
}
},
fail: () => {
uni.hideLoading();
},
}); });
this.fileList = arry;
}, },
// //
oversize(e) { oversize(e) {
this.$u.toast("请传10MB以内大小的图片/视频!"); this.$u.toast("请传10MB以内大小的图片/视频!");
return false; return false;
}, },
// //
async afterRead(event) { onDelete(event) {
let lists = [].concat(event.file); this[`fileList${event.name}`].splice(event.index, 1);
let fileListLen = this[`fileList${event.name}`].length; var arry = [];
lists.map((item) => { this.fileList.filter((v, i) => {
this[`fileList${event.name}`].push({ arry.push({
...item, name: v.name || "",
status: "uploading", format: v.type,
message: "上传中", url: v.url,
}); });
}); });
for (let i = 0; i < lists.length; i++) { this.form.imageList = arry;
const result = await uploadImage(lists[i].url);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
}
console.log(this.fileList);
this.fileList = this.fileList.map((v) => ({
url: v.url,
name: v.name,
type: v.type,
}));
}, },
// //
async getRoomDetail() { async getRoomDetail() {

383
pagesA/xjPage/xj.vue

@ -6,44 +6,99 @@
<view class="xjTips">请您填写相关问题</view> <view class="xjTips">请您填写相关问题</view>
<view class="conItem"> <view class="conItem">
<u-form labelPosition="left"> <u-form labelPosition="left">
<u-form-item
<u-form-item labelAlign="right" labelWidth="100px" label="乐业社区" prop="sex" borderBottom labelAlign="right"
@click="lysqShow = true" required> labelWidth="100px"
<u--input v-model="form.apartmentName" disabled disabledColor="#ffffff" placeholder="请选择" border="none"></u--input> label="乐业社区"
prop="sex"
borderBottom
@click="lysqShow = true"
required
>
<u--input
v-model="form.apartmentName"
disabled
disabledColor="#ffffff"
placeholder="请选择"
border="none"
></u--input>
<u-icon slot="right" name="arrow-right"></u-icon> <u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item> </u-form-item>
<u-form-item labelAlign="right" labelWidth="100px" label="巡检问题类型" borderBottom <u-form-item
@click="wtlxShow = true" required> labelAlign="right"
<u--input v-model="form.questionName" disabled disabledColor="#ffffff" placeholder="请选择" border="none"></u--input> labelWidth="100px"
label="巡检问题类型"
borderBottom
@click="wtlxShow = true"
required
>
<u--input
v-model="form.questionName"
disabled
disabledColor="#ffffff"
placeholder="请选择"
border="none"
></u--input>
<u-icon slot="right" name="arrow-right"></u-icon> <u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item> </u-form-item>
<u-form-item labelAlign="right" labelWidth="100px" label="标题内容" borderBottom required> <u-form-item
<u--textarea v-model="form.title" placeholder="请输入内容" count maxlength="500"></u--textarea> labelAlign="right"
labelWidth="100px"
label="标题内容"
borderBottom
required
>
<u--textarea
v-model="form.title"
placeholder="请输入内容"
count
maxlength="500"
></u--textarea>
</u-form-item> </u-form-item>
<u-form-item labelAlign="right" labelWidth="100px" label="问题描述" borderBottom required> <u-form-item
<u--textarea v-model="form.content" placeholder="请输入内容" count maxlength="500"></u--textarea> labelAlign="right"
labelWidth="100px"
label="问题描述"
borderBottom
required
>
<u--textarea
v-model="form.content"
placeholder="请输入内容"
count
maxlength="500"
></u--textarea>
</u-form-item> </u-form-item>
<u-form-item labelAlign="right" labelWidth="120px" label="上传图片/视频" borderBottom> <u-form-item
labelAlign="right"
labelWidth="120px"
label="上传图片/视频"
borderBottom
>
<u-upload <u-upload
v-model="fileList"
:max-count="10" :max-count="10"
:multiple="true" :multiple="true"
:preview-full-image="true" :preview-full-image="true"
:deletable="true" :deletable="true"
:show-upload-list="true" :show-upload-list="true"
:fileList="fileList" :fileList="fileList"
:auto-upload="false"
accept="all" accept="all"
@afterRead="afterRead"
@delete="onDelete"
:maxSize="10 * 1024 * 1024" :maxSize="10 * 1024 * 1024"
@oversize="oversize" @oversize="oversize"
@delete="onDelete"
:disabled="true"
> >
<view class="custom-upload-btn"> <view class="custom-upload-btn" @click.stop="chooseImage">
<view class="icon-box"> <view class="icon-box">
<image class="camera-icon" src="/static/img/camera-icon.png" mode="aspectFill"></image> <image
class="camera-icon"
src="/static/img/camera-icon.png"
mode="aspectFill"
></image>
</view> </view>
<view class="upload-tips">点击上传</view> <view class="upload-tips">点击上传</view>
</view> </view>
@ -52,12 +107,24 @@
</u-form> </u-form>
</view> </view>
<view class="conItem" style="margin-top: 40rpx;"> <view class="conItem" style="margin-top: 40rpx">
<u--form labelPosition="left"> <u--form labelPosition="left">
<u-form-item labelAlign="right" labelWidth="100px" label="巡检人姓名" borderBottom required> <u-form-item
labelAlign="right"
labelWidth="100px"
label="巡检人姓名"
borderBottom
required
>
<u--input v-model="form.inspector" border="none"></u--input> <u--input v-model="form.inspector" border="none"></u--input>
</u-form-item> </u-form-item>
<u-form-item labelAlign="right" labelWidth="100px" label="巡检人电话" borderBottom required> <u-form-item
labelAlign="right"
labelWidth="100px"
label="巡检人电话"
borderBottom
required
>
<u--input v-model="form.inspectorPhone" border="none"></u--input> <u--input v-model="form.inspectorPhone" border="none"></u--input>
</u-form-item> </u-form-item>
</u--form> </u--form>
@ -65,19 +132,29 @@
<view class="btn" @click="handleBtn">提交</view> <view class="btn" @click="handleBtn">提交</view>
<u-action-sheet :show="lysqShow" :actions="apartmentList" title="请选择乐业社区" @close="lysqShow = false" @select="handleTreeSelect"> <u-action-sheet
:show="lysqShow"
:actions="apartmentList"
title="请选择乐业社区"
@close="lysqShow = false"
@select="handleTreeSelect"
>
</u-action-sheet> </u-action-sheet>
<u-action-sheet :show="wtlxShow" :actions="questionTypeList" title="请选择问题类型" @close="wtlxShow = false" @select="handleQuestionSelect"> <u-action-sheet
:show="wtlxShow"
:actions="questionTypeList"
title="请选择问题类型"
@close="wtlxShow = false"
@select="handleQuestionSelect"
>
</u-action-sheet> </u-action-sheet>
</scroll-view> </scroll-view>
</template> </template>
<script> <script>
import { import { queryDeptDropdownList } from "@/common/rec";
queryDeptDropdownList, import { getdeptList, addInspection } from "@/common/api";
} from "@/common/rec"; import { uploadImage } from "@/pages/api";
import { getdeptList,addInspection } from '@/common/api';
import { uploadImage } from '@/pages/api.js';
import { getDicts } from "@/common/system/dict/data"; import { getDicts } from "@/common/system/dict/data";
export default { export default {
@ -88,91 +165,94 @@ export default {
deptOptions: [], deptOptions: [],
questionTypeList: [], questionTypeList: [],
form: { form: {
apartmentId: '', apartmentId: "",
apartmentName:'', apartmentName: "",
questionType: '', questionType: "",
questionName: '', questionName: "",
title: '', title: "",
content: '', content: "",
inspector: '', inspector: "",
inspectorPhone: '', inspectorPhone: "",
inspectionTime: '', inspectionTime: "",
imageList: [] imageList: [],
}, },
rules: { rules: {
sex:[ sex: [{ required: true, message: "请输入", trigger: "blur" }],
{ required: true, message: '请输入', trigger: 'blur' }
]
}, },
radio: '', radio: "",
switchVal: false, switchVal: false,
fileList: [], fileList: [],
apartmentList:[] apartmentList: [],
} };
}, },
onLoad() { onLoad() {
this.getTree() this.getTree();
this.getDictType() this.getDictType();
}, },
methods: { methods: {
async afterRead(event) { chooseImage() {
let lists = [].concat(event.file); uni.chooseImage({
let fileListLen = this[`fileList${event.name}`].length; count: 10 - this.fileList.length,
lists.map((item) => { sizeType: ["original", "compressed"],
this[`fileList${event.name}`].push({ sourceType: ["album", "camera"],
...item, success: async (res) => {
status: "uploading", uni.showLoading({ title: "上传中...", mask: true });
message: "上传中", try {
}); // H5
}); const files =
for (let i = 0; i < lists.length; i++) { res.tempFiles || res.tempFilePaths.map((path) => ({ path }));
const result = await uploadImage(lists[i].url); for (let i = 0; i < files.length; i++) {
let item = this[`fileList${event.name}`][fileListLen]; const filePath = files[i].path;
//
this[`fileList${event.name}`].splice( const uploadRes = await uploadImage(filePath);
fileListLen, //
1, this.fileList.push({
Object.assign(item, { url: uploadRes.data?.url || uploadRes.url || uploadRes.path, //
name: uploadRes.data?.name || uploadRes.name || "",
type: uploadRes.data?.type || uploadRes.type || "image",
status: "success", status: "success",
message: "", });
url: result.url,
})
);
fileListLen++;
} }
var arry = []; // form.imageList
this.fileList.filter((v, i) => { this.form.imageList = this.fileList.map((v) => ({
arry.push({ name: v.name || "",
name: v.name || '',
format: v.type, format: v.type,
url:v.url url: v.url,
}); }));
} catch (e) {
uni.showToast({ title: "上传失败", icon: "none" });
} finally {
uni.hideLoading();
}
},
fail: () => {
uni.hideLoading();
},
}); });
this.form.imageList = arry },
//
oversize(e) {
this.$u.toast("请传10MB以内大小的图片/视频!");
return false;
}, },
onDelete(event) { onDelete(event) {
this[`fileList${event.name}`].splice(event.index, 1); this[`fileList${event.name}`].splice(event.index, 1);
var arry = []; var arry = [];
this.fileList.filter((v, i) => { this.fileList.filter((v, i) => {
arry.push({ arry.push({
name: v.name || '', name: v.name || "",
format: v.type, format: v.type,
url:v.url url: v.url,
}); });
}); });
this.form.imageList = arry this.form.imageList = arry;
},
//
oversize(e) {
this.$u.toast("请传10MB以内大小的图片/视频!");
return false;
}, },
getDictType() { getDictType() {
getDicts('inspection_question_type').then((res) => { getDicts("inspection_question_type").then((res) => {
this.questionTypeList = res.data.map(item=>{ this.questionTypeList = res.data.map((item) => {
item.name = item.dictLabel item.name = item.dictLabel;
return item return item;
}) });
}); });
}, },
getTree() { getTree() {
@ -184,13 +264,13 @@ export default {
"children", "children",
2 2
); );
console.log(this.deptOptions,'this.deptOptions'); console.log(this.deptOptions, "this.deptOptions");
const deptInfo = this.deptOptions[0].children[0] const deptInfo = this.deptOptions[0].children[0];
const newArr = this.deptOptions.map(item => ({ const newArr = this.deptOptions.map((item) => ({
name: item.deptName, name: item.deptName,
})) }));
this.apartmentList = newArr this.apartmentList = newArr;
// this.deptOptions = await this.getListByParentId("1", deptInfo.deptId); // this.deptOptions = await this.getListByParentId("1", deptInfo.deptId);
// console.log(this.deptOptions); // console.log(this.deptOptions);
}); });
@ -207,93 +287,94 @@ export default {
console.log(this.form); console.log(this.form);
if (!this.form.apartmentId) { if (!this.form.apartmentId) {
uni.showToast({ uni.showToast({
icon: 'none', icon: "none",
title: '请选择乐业社区' title: "请选择乐业社区",
}) });
return return;
} else if (!this.form.questionType) { } else if (!this.form.questionType) {
uni.showToast({ uni.showToast({
icon: 'none', icon: "none",
title: '巡检问题类型' title: "巡检问题类型",
}) });
return return;
} else if (!this.form.title) { } else if (!this.form.title) {
uni.showToast({ uni.showToast({
icon: 'none', icon: "none",
title: '请输入标题内容' title: "请输入标题内容",
}) });
return return;
} else if (!this.form.content) { } else if (!this.form.content) {
uni.showToast({ uni.showToast({
icon: 'none', icon: "none",
title: '请输入问题描述' title: "请输入问题描述",
}) });
return return;
} else if (!this.form.inspector) { } else if (!this.form.inspector) {
uni.showToast({ uni.showToast({
icon: 'none', icon: "none",
title: '请输入巡检人姓名' title: "请输入巡检人姓名",
}) });
return return;
} else if (!this.form.inspectorPhone) { } else if (!this.form.inspectorPhone) {
uni.showToast({ uni.showToast({
icon: 'none', icon: "none",
title: '请输入巡检人电话' title: "请输入巡检人电话",
}) });
return return;
} }
// console.log(this.form); // console.log(this.form);
let parmas = JSON.parse(JSON.stringify(this.form)) let parmas = JSON.parse(JSON.stringify(this.form));
delete parmas.apartmentName delete parmas.apartmentName;
delete parmas.questionName delete parmas.questionName;
addInspection(parmas).then(res=>{ addInspection(parmas).then((res) => {
if (res.code == 200) { if (res.code == 200) {
uni.showToast({ uni.showToast({
icon: 'success', icon: "success",
title: '提交成功!', title: "提交成功!",
success: () => { success: () => {
this.fileList = [] this.fileList = [];
this.form = { this.form = {
apartmentId: '', apartmentId: "",
apartmentName:'', apartmentName: "",
questionType: '', questionType: "",
questionName: '', questionName: "",
title: '', title: "",
content: '', content: "",
inspector: '', inspector: "",
inspectorPhone: '', inspectorPhone: "",
inspectionTime: '', inspectionTime: "",
imageList: [] imageList: [],
} };
setTimeout(() => { setTimeout(() => {
uni.switchTab({ uni.switchTab({
url: '/pages/tabBar/work/index' url: "/pages/tabBar/work/index",
}); });
},2000) }, 2000);
}, },
});
})
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg || "提交失败", title: res.msg || "提交失败",
icon: "none", icon: "none",
}); });
} }
}) });
}, },
handleTreeSelect(e) { handleTreeSelect(e) {
console.log(e); console.log(e);
console.log(this.deptOptions); console.log(this.deptOptions);
this.form.apartmentName = e.name this.form.apartmentName = e.name;
this.form.apartmentId = this.deptOptions.find(item=>item.deptName === e.name).deptId this.form.apartmentId = this.deptOptions.find(
(item) => item.deptName === e.name
).deptId;
}, },
handleQuestionSelect(e) { handleQuestionSelect(e) {
this.form.questionName = e.dictLabel this.form.questionName = e.dictLabel;
this.form.questionType = e.dictValue this.form.questionType = e.dictValue;
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -346,7 +427,12 @@ export default {
height: 70rpx; height: 70rpx;
line-height: 70rpx; line-height: 70rpx;
border-radius: 600rpx; border-radius: 600rpx;
background: linear-gradient(86.25deg, rgba(13, 198, 198, 1) 3.03%, rgba(19, 194, 194, 1) 3.03%, rgba(70, 219, 213, 1) 96.43%); background: linear-gradient(
86.25deg,
rgba(13, 198, 198, 1) 3.03%,
rgba(19, 194, 194, 1) 3.03%,
rgba(70, 219, 213, 1) 96.43%
);
color: rgba(255, 255, 255, 1); color: rgba(255, 255, 255, 1);
font-size: 34rpx; font-size: 34rpx;
text-align: center; text-align: center;
@ -404,5 +490,4 @@ export default {
font-size: 24rpx !important; font-size: 24rpx !important;
} }
} }
</style> </style>

Loading…
Cancel
Save