123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734 |
- <template>
- <view>
- <view class="align-items" style="margin-top: 80rpx;">
- <back></back>
- <view class="title-text" style="margin-left: 20rpx;">
- 阀管施工
- </view>
- </view>
- <view style="margin-top: 60rpx;">
- <view>
- <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('xiaoqu')">
- {{house ? house :'选择小区'}}
- <u-popup v-model="pop" mode="bottom" height="1000rpx">
- <view style="margin: 20rpx;">
- <u-search placeholder="请输入搜索内容" v-model="keyword" :action-style="{'font-size':'40rpx'}" @custom="searchinfo(selectType)"></u-search>
- </view>
- <view>
- <scroll-view scroll-y="true" style="height: 600rpx; text-align: center;">
- <view v-for="(item,index) in chooseHouseList" :key="item.value" >
- <view :class="current === index ? 'active' : '' " style="color: #000000;" @click="active(item,index)">
- {{item.label}}
- </view>
- </view>
- </scroll-view>
- <view class="">
- <button type="default" class="font-fifty-six" @click="search(selectType)">确定</button>
- </view>
- <view class="">
- <button type="default" @click="pop = false;" class="font-fifty-six">取消</button>
- </view>
- </view>
- </u-popup>
- <!-- <u-select v-model="houseShow" :list="chooseHouseList" @confirm="chooseHouse"></u-select> -->
- </view>
- </view>
-
- <view>
- <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('louyu')">
- {{bulid ? bulid : '选择楼宇'}}
- <!-- <u-select v-model="bulidShow" :list="chooseBuildList" @confirm="chooseBuild"></u-select> -->
- </view>
- </view>
- <view>
- <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('danyuan')">
- {{unit ? unit : '选择单元'}}
- <!-- openUnit(), <u-select v-model="unitShow" :list="chooseUnitList" @confirm="chooseUnit"></u-select> -->
- </view>
- </view>
- <view>
- <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('menpai')">
- {{houseNumber ? houseNumber : '选择门牌'}}
- <!-- open(), <u-select v-model="houseNumberShow" :list="chooseNumberList" @confirm="chooseNumber"></u-select> -->
- </view>
- </view>
- <view>
- <view class="font-fifty-six SourceHanSansCN select-type" @click="openType('shows')">
- 上门类型 <text class="font-fifty-six SourceHanSansCN" style="color: #232146;">
- {{type ? '----' + type : ''}}</text>
- <u-select v-model="shows" :list="mounicipalList" @confirm="confirm"></u-select>
- </view>
- <view v-if="typeValue">
- <view v-if=" typeValue === '002' ">
- <view class="font-fifty-six SourceHanSansCN select-type" @click="projectType()">
- 自闭阀类型 <text class="font-fifty-six SourceHanSansCN" style="color: #232146;">
- {{valueType ? '----' + valueType : ''}}</text>
- <u-select v-model="listTypeShow" :list="typeList" @confirm="listType"></u-select>
- </view>
- <view class="font-fifty-six SourceHanSansCN tube" @click="openType('tubeType')">
- 管子类别
- <text class="font-fifty-six SourceHanSansCN" style="color: #232146;">
- {{tubeType ?'----' + tubeType:''}}</text>
- <u-select v-model="tubeTypeShow" :list="tubeTypeList" @confirm="tubeTypeConfirm"></u-select>
- </view>
- <view class="font-fifty-six SourceHanSansCN tube" @click="openType('tubeLong')">
- 管子长度
- <text class="font-fifty-six SourceHanSansCN" style="color: #232146;">
- {{tubeLong ?'----' + tubeLong :''}}</text>
- <u-select v-model="tubeLongShow" :list="tubeTypeLongList" @confirm="tubeLongConfirm">
- </u-select>
- </view>
- </view>
- <view class="upload align-items">
- <view class="" style="display: flex; flex-wrap: wrap;">
- <image src="/static/icon/chooseimg.png" mode=""
- style="width: 190rpx; height: 190rpx; margin: 0 12rpx;; " @click="choose()"></image>
- <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
- <view v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ">
- <image :src="item" mode=""
- style="width: 190rpx; height: 190rpx; margin: 0 12rpx;" @click="showPhoto(index)">
- </image>
- </view>
- <view v-else>
- <video :src="item"
- style="width: 190rpx; height: 190rpx; margin: 0 12rpx;"></video>
- </view>
- <view @click="remove(index)" style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
- <u-icon name="close" color="#FFFFFF" size="35" ></u-icon>
- </view>
- </view>
- </view>
- <view class="gray font-forty-eight SourceHanSansCN" v-if="photo">
- 此处添加照片或视频
- </view>
- </view>
- <view class="upload">
- <text class="font-forty SourceHanSansCN">备注:</text>
- <textarea value="" placeholder="请输入备注" v-model="remark"/>
- </view>
- </view>
-
- <view class="font-fifty-six SourceHanSansCN total background-color1" @click="submit()">
- 提交数据
- </view>
- <!-- <u-select v-model="shows" :list="mounicipalList" @confirm="confirm"></u-select> -->
- <!-- <u-select v-model="tubeTypeShow" :list="tubeTypeList" @confirm="tubeTypeConfirm"></u-select> -->
- <!-- <u-select v-model="tubeLongShow" :list="tubeTypeLongList" @confirm="tubeLongConfirm"></u-select> -->
- </view>
- </view>
- </view>
- </template>
- <script>
- import service from '@/api/index.js'
- export default {
- components: {
- },
- data() {
- return {
- keyword:'',
- selectType:'',
- pop:false,
- housename:'',
- houseid:0,
- buildid:0,
- unitid:0,
- numberid:0,
- houseShow: false,
- current:-1,
- chooseHouseList: [],
- house: '选择小区',
- bulid: '选择楼宇',
- unit: '选择单元',
- houseNumber: '选择门牌',
- action: this.$HTTP.webUrl + `/obs`,
- shows: false,
- tubeTypeShow: false,
- tubeLongShow: false,
- mounicipalList: [],
- tubeTypeList: [],
- tubeTypeLongList: [],
- type: '',
- tubeType: '',
- tubeLong: '',
- // url: [],
- photo: true,
- typeValue: '',
- headers: {
- MAuthorization: "wxBearer " + uni.getStorageSync('token')
- },
- housedata: '',
- typeList: [],
- listTypeShow: false,
- valueType: '',
- uploading: false,
- imgArr:[],
- remark:'',
- show:false,
- progress:0 ,//上传图片进度百分比
- loading:false
- }
- },
- onLoad() {
- this.getArea();
- this.select();
- this.getTubeType();
- this.getTubeLong();
- this.getProjectType();
- },
- methods: {
- openHouse(selectType) {
- if(selectType === 'xiaoqu'){
- //选择小区
- this.selectType = 'xiaoqu'
- this.getArea();
- }else if(selectType === 'louyu'){
- //选择楼宇
- this.selectType = 'louyu'
- this.housename = null;
- this.buildid = 0;
- service.getBuilding({areaId: this.houseid}).then(res => {
- this.chooseHouseList = [];
- res.forEach(item => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'louyu'
- })
- })
- })
-
- }else if(selectType === 'danyuan'){
- //选择单元
- this.selectType = 'danyuan';
- this.housename = null;
- this.unitid = 0;
- service.getUnit({buildingId: this.buildid}).then(res => {
- this.chooseHouseList = [];
- res.forEach(item => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'danyuan'
- })
- })
- })
-
- }else if(selectType === 'menpai'){
- //选择门牌
- this.selectType = 'menpai';
- this.housename = null;
- this.numberid = null;
- service.getHouse({unitId: this.unitid}).then(res => {
- this.chooseHouseList = [];
- res.forEach(item => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'menpai'
- })
- })
- })
- }
- this.pop = !this.pop;
- },
- searchinfo(selectType){
- if(selectType == 'xiaoqu'){
- console.log('ssss',this.selectType)
- service.getArea({name:this.keyword}).then(res => {
- this.chooseHouseList = [];
- res.forEach((item, index) => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'xiaoqu'
- })
- })
- })
- this.keyword = '';
- }else if(selectType == 'louyu'){
- console.log('ssss',this.selectType)
- service.getBuilding({areaId: this.houseid,name:this.keyword}).then(res => {
- this.chooseHouseList = [];
- res.forEach((item, index) => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'louyu'
- })
- })
- })
- this.keyword = '';
- }else if(selectType == 'danyuan'){
- console.log('ssss',this.selectType)
- service.getUnit({buildingId: this.buildid,name:this.keyword}).then(res => {
- this.chooseHouseList = [];
- res.forEach((item, index) => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'danyuan'
- })
- })
- })
- this.keyword = '';
- }else if(selectType == 'menpai'){
- console.log('ssss',this.selectType)
- service.getHouse({unitId: this.unitid,name:this.keyword}).then(res => {
- this.chooseHouseList = [];
- res.forEach((item, index) => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'menpai'
- })
- })
- })
- this.keyword = '';
- }
-
- },
- showPhoto(index){
- uni.previewImage({
- current:index,
- urls:this.imgArr,
- })
- console.log('sss')
- },
- openBuild() {
- this.bulidShow = !this.bulidShow
- },
- projectType() {
- this.listTypeShow = !this.listTypeShow
- },
- //获取小区
- getArea() {
- service.getArea().then(res => {
- this.chooseHouseList = [];
- res.forEach((item, index) => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'xiaoqu'
- })
- })
- })
- },
- getProjectType() {
- service.getProject().then(res => {
- console.log('getProjectType', res)
- this.typeList = [];
- res.forEach(item => {
- this.typeList.push({
- value: item.id,
- label: item.valveType
- })
- })
- })
- },
- search(selectType){
- if(selectType == 'xiaoqu'){
- this.house = this.housename;
- service.getBuilding({areaId: this.houseid}).then(res => {
- this.chooseHouseList = [];
- res.forEach(item => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'louyu'
- })
- })
- })
- this.current = -1;
- this.bulid = null;
- this.unit = null;
- this.houseNumber = null;
- }else if(selectType == 'louyu'){
- this.bulid = this.housename;
- service.getUnit({buildingId: this.buildid}).then(res => {
- this.chooseHouseList = [];
- res.forEach(item => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'danyuan'
- })
- })
- })
-
- this.unit = null;
- this.houseNumber = null;
- this.current = -1;
- }else if(selectType == 'danyuan'){
- this.unit = this.housename;
- service.getHouse({unitId: this.unitid}).then(res => {
- this.chooseHouseList = [];
- res.forEach(item => {
- this.chooseHouseList.push({
- value: item.id,
- label: item.name,
- selectType:'menpai'
- })
- })
- })
- this.houseNumber = null;
- this.current = -1;
-
- }else if(selectType == 'menpai'){
- this.houseNumber = this.housename;
- this.housedata = this.numberid;
- this.current = -1;
- }
- this.pop = false;
- },
- active(item,index){
- this.current = index;
- this.housename = item.label;
- if(item.selectType == 'xiaoqu'){
- this.houseid = item.value;
- }else if(item.selectType == 'louyu'){
- this.buildid = item.value;
- }else if(item.selectType == 'danyuan'){
- this.unitid = item.value;
- }else if(item.selectType == 'menpai'){
- this.numberid = item.value
- }
- this.selectType = item.selectType;
- },
-
- openUnit() {
- this.unitShow = !this.unitShow
- },
- //选择门牌
-
- open() {
- this.houseNumberShow = !this.houseNumberShow
- },
- //选择上门类型
- confirm(e) {
- this.type = e[0].label
- this.typeValue = e[0].value
- this.imgArr = [];
- this.tubeType = null;
- this.tubeLong = null;
- this.valueType = null;
- this.photo = true;
- },
- //选择类型
- select() {
- service.getDic({
- dicType: 'service_type'
- }).then(res => {
- res.forEach(item => {
- this.mounicipalList.push({
- value: item.value,
- label: item.name
- })
- })
- })
- },
- openType(type) {
- if (type === 'shows') {
- this.shows = !this.shows
- } else if (type === 'tubeType') {
- this.tubeTypeShow = !this.tubeTypeShow
- } else {
- this.tubeLongShow = !this.tubeLongShow
- }
- },
- tubeTypeConfirm(e) {
- this.tubeType = e[0].label
- },
- listType(e) {
- this.valueType = e[0].label
- },
- tubeLongConfirm(e) {
- this.tubeLong = e[0].label
- },
- getTubeType() {
- service.getPipeType().then(res => {
- res.forEach(item => {
- this.tubeTypeList.push({
- value: item.id,
- label: item.pipeType
- })
- })
- })
- },
- getTubeLong() {
- service.getPipeLength().then(res => {
- res.forEach(item => {
- this.tubeTypeLongList.push({
- value: item.id,
- label: item.pipeLength
- })
- })
- })
- },
- remove(index) {
- uni.showModal({
- title: '提示',
- content: '是否删除该图片或视频?',
- success: (res) => {
- if (res.confirm) {
- this.imgArr.splice(index, 1)
- console.log('this.imgarr',this.imgArr)
- if (this.imgArr.length <= 0) {
- this.photo = true;
- }
- }
- }
- })
- },
- choose() {
- let _this = this;
- uni.showActionSheet({
- title:'上传',
- itemList:['图片','视频'],
- success: (res) => {
- console.log(res)
- if(res.tapIndex == 0){
- this.chooseimage()
- }else{
- this.choosevideo()
- }
- }
- })
- },
- chooseimage() {
- console.log('图片')
- let _this = this;
- uni.chooseImage({
- sizeType: ['album', 'camera'],
- success(resp) {
- console.log('res--uni.chooseMedia', resp);
- resp.tempFiles.forEach((item, index) => {
- const task = uni.uploadFile({
- url: _this.$HTTP.webUrl + `/obs`,
- filePath: item.path,
- name: 'file',
- formData: {},
- header: _this.headers,
- success: res => {
- // 判断是否json字符串,将其转为json格式
- let data = _this.$u.test.jsonString(res
- .data) ? JSON.parse(res.data) : res.data;
- if (![200, 201, 204].includes(res.statusCode)) {
- // this.uploadError(index, data);
- _this.$UTILS.showPrompt('上传失败!')
- } else {
- if (_this.progress === 100) {
- console.log('_this.progress', _this.progress)
- console.log('data----', data)
- console.log('res--', res)
- _this.imgArr.push(data.data.url)
- console.log('imgArr', _this.imgArr)
- _this.$UTILS.showPrompt('上传成功!')
- _this.photo = false;
- }
- }
- },
- fail: e => {
- _this.$UTILS.showPrompt('上传失败!')
- this.uploadError(index, e);
- },
- complete: res => {
- uni.hideLoading();
- _this.uploading = false;
-
- }
- });
- task.onProgressUpdate(res => {
- _this.progress = res.progress;
- console.log('onProgressUpdate', res)
- console.log('task.onProgressUpdate', _this.progress)
- uni.showLoading({
- title: '上传中'
- })
- if(_this.progress != 100){
- _this.loading = false
- console.log('_this.loading false', _this.loading)
- }else {
- _this.loading = true
- console.log('_this.loading true', _this.loading)
- }
- });
-
- })
-
- },
- })
- },
- choosevideo() {
- let _this = this;
- console.log('视频')
- uni.chooseVideo({
- sourceType: ['album','camera'],
- maxDuration: 30,
- success(resp) {
- const task = uni.uploadFile({
- url: _this.$HTTP.webUrl + `/obs`,
- filePath: resp.tempFilePath,
- name: 'file',
- formData: {},
- header: _this.headers,
- success: res => {
- // 判断是否json字符串,将其转为json格式
- let data = _this.$u.test.jsonString(res
- .data) ? JSON.parse(res.data) : res.data;
- if (![200, 201, 204].includes(res.statusCode)) {
- this.uploadError(index, data);
- } else {
- //上传成功
- if (_this.progress === 100) {
- console.log('_this.progress', _this.progress)
- _this.imgArr.push(data.data.url)
- console.log('imgArr', _this.imgArr)
- _this.$UTILS.showPrompt('上传成功!')
- _this.photo = false;
- }
- }
- },
- fail: e => {
- _this.$UTILS.showPrompt('上传失败!')
- this.uploadError(index, e);
- },
- complete: res => {
- uni.hideLoading();
- _this.uploading = false;
- }
- });
- task.onProgressUpdate(res => {
- _this.progress = res.progress;
- console.log('onProgressUpdate', res)
- uni.showLoading({
- title: '上传中'
- })
- if(_this.progress != 100){
- _this.loading = false
- console.log('_this.loading false', _this.loading)
- }else {
- _this.loading = true
- console.log('_this.loading true', _this.loading)
- }
- });
-
- },
- })
- },
- submit() {
- if (!this.housedata) {
- this.$UTILS.showPrompt('请选择门牌号!')
- return
- }
- if (!this.type) {
- this.$UTILS.showPrompt('请选择上门类型!')
- return
- }
- if (this.typeValue == '002') {
- if (!this.valueType) {
- this.$UTILS.showPrompt('请选择自闭阀类别!')
- return
- }
- if (!this.tubeType) {
- this.$UTILS.showPrompt('请选择管子类型!')
- return
- }
- if (!this.tubeLong) {
- this.$UTILS.showPrompt('请选择管子长度!')
- return
- }
- }
- if (this.imgArr.length <= 0) {
- this.$UTILS.showPrompt('请上传照片或视频!')
- return
- }
- if(this.loading == false) {
- this.$UTILS.showPrompt('照片或视频未上传完毕,无法提交!')
- return
- }
- let param = {
- serviceType: this.typeValue,
- pipeType: this.tubeType,
- pipeLength: this.tubeLong,
- houseId: this.housedata,
- valveType: this.valueType,
- picUrl: this.imgArr,
- remark: this.remark,
- }
- console.log('param-----', param)
- service.submitOrder(param).then(res => {
- this.$UTILS.showPrompt('提交成功!')
- this.houseNumber = null;
- this.type = null;
- this.typeValue = null;
- this.valueType = null;
- this.tubeType = null;
- this.tubeLong = null;
- this.housedata = null;
- this.typeValue = null;
- this.remark = null;
- this.imgArr = [];
- }).catch(e => {
- this.$UTILS.showPrompt('提交失败!')
- console.error(e)
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .choose {
- text-align: center;
- padding: 20rpx;
- margin: 30rpx;
- color: #FFFFFF;
- background: #43CEB1;
- border-radius: 64rpx;
- }
- .active{
- background-color: #1890FF;
- }
- .select-type {
- border: 2rpx solid #3857F3;
- text-align: center;
- padding: 20rpx;
- margin: 30rpx;
- color: #3857F3;
- border-radius: 64rpx;
- }
- .upload {
- margin: 30rpx;
- padding: 30rpx 20rpx;
- border: 2rpx solid #3857F3;
- border-radius: 48rpx;
- }
- .tube {
- text-align: center;
- padding: 20rpx;
- margin: 30rpx;
- color: #43CEB1;
- border: 2rpx solid #43CEB1;
- border-radius: 64rpx;
- }
- .total {
- width: 100%;
- padding: 40rpx 30rpx;
- text-align: center;
- color: #FFFFFF;
- }
- </style>
|