popup.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view>
  3. <!-- 弹窗 -->
  4. <view class="bgbox" @click="getClose" v-if="type"></view>
  5. <!-- 指派 -->
  6. <view v-if="type=='assign'" class="assignbox">
  7. <view class="assbox">
  8. <view class="asstit">报修指派</view>
  9. <picker range-key='dictLabel' disabled="true" :value="syqxidx" :range="sexs" @change='bindDateChange'>
  10. <view class="flexc asline">
  11. <!-- <view class="flex1 f13" :class="datainfo.iszc?'co27':'coa'">{{datainfo.iszc?'是':'请选择维修类型'}}</view> -->
  12. <view class="flex1 co27 f13">{{kaType(bxlb,bxlbList)}}</view>
  13. <view class="rimg"><image :src="rimg"></image></view>
  14. </view>
  15. </picker>
  16. <view class="tabtit">选择维修师傅</view>
  17. <view class="asslists">
  18. <view class="asslist" :class="peoval==ite.staffId?'act':''" v-for="(ite,idx) in peolist" :key="idx" @click="getChose(ite.staffId,ite)">
  19. <image :src="headbg" v-if="peoval==ite.staffId"></image>
  20. <view class="altit">{{ite.staffName}}</view>
  21. <view class="altxt " :class="{'cof6':ite.status==2,'co28':ite.status==1,}">{{kaType(ite.status,vxsztList)}}</view>
  22. <!-- <view class="altxt co28" v-if="ite.status==1">空闲中</view> -->
  23. </view>
  24. </view>
  25. <view class="rhbtn" @click="getSure('assign')">确定</view>
  26. </view>
  27. <image :src="closeimg" class="closeimg" @click="getClose"></image>
  28. </view>
  29. <!-- 上门打卡 -->
  30. <view v-if="type=='assigncheck'" class="assignbox pra">
  31. <view class="assbox">
  32. <view class="asstit">{{finshtype==3?'完成打卡':'上门打卡'}}</view>
  33. <view class="assadd" @click="getaddImage">
  34. <image :src="addpho"></image>
  35. <view>去拍照</view>
  36. </view>
  37. <view class="assimgs" v-if="phofile&&phofile.length">
  38. <view class="assimg" v-for="(ite,idx) in phofile" :key="idx" @click="getPreview(idx,phofile)">
  39. <image :src="baseUrl+ite" class="img"></image>
  40. <image :src="rdelimg" class="delimg" @click.stop="getDelFn(idx)"></image>
  41. </view>
  42. </view>
  43. <view class="rhbtn" @click="getSure('assigncheck')">确定</view>
  44. </view>
  45. <image :src="closeimg" class="closeimg" @click="getClose"></image>
  46. </view>
  47. <!-- 建议回复 -->
  48. <view v-if="type=='reply'" class="assignbox pra">
  49. <view class="assbox">
  50. <view class="asstit">回复</view>
  51. <uni-easyinput maxlength='200' type="textarea" autoHeight v-model="text" :inputBorder='false' placeholder="请输入回复内容,最多不超过200字…" />
  52. <view class="voice mb20">
  53. <view class="flexc" @click="getVoiceFn">
  54. <image :src="voice"></image>
  55. 语音输入
  56. </view>
  57. </view>
  58. <view class="fjtxt mb18 flexcj">附件信息
  59. <lsj-upload ref="lsjUpload" childId="upload1" :width="width" :height="height" :option="option" :size="size" :formats="formats" :debug="debug" :instantly="instantly"
  60. @progress="" @uploadEnd="onuploadEnd" fileVal="1" bigType="1">
  61. <!-- fileName="123" fileVal='dbxmhfhgb' bigType="c" -->
  62. <view class="fjbtns co02" :style="{width: width,height: height}">上传附件</view>
  63. </lsj-upload>
  64. </view>
  65. <view class="fjlists" v-for="(fite,fidx) in filelist" :key='fidx'>
  66. <view class="flext" @click="getDownloader(fite.url)">
  67. <view class="imgl"><image :src="filico" ></image></view>
  68. <view class="tit">{{fite.name}}</view>
  69. </view>
  70. <view class="delimg flex0" @click.stop="getDelFj(fidx)">
  71. <image :src="fdelimg"></image>
  72. </view>
  73. </view>
  74. <view class="rhbtn mt40" @click="getSure('reply')">确定</view>
  75. </view>
  76. <image :src="closeimg" class="closeimg" @click="getClose"></image>
  77. </view>
  78. <voice-input :voiceflag="voiceflag" @getVoice="getVoice" @getClose="getvoiceClose"></voice-input>
  79. </view>
  80. </template>
  81. <script>
  82. import self from '@/utils/location.js';
  83. import config from '@/config'
  84. const baseUrl = config.baseUrl
  85. const baseName = config.baseName
  86. const Clientid = config.Clientid
  87. import { getToken } from '@/utils/auth'
  88. import {uploadmore} from '@/utils/common.js'
  89. import {selectDictValue} from "@/utils/common.js"
  90. import voiceInput from "@/service/components/popup/voice.vue"
  91. export default{
  92. components:{voiceInput},
  93. props:{
  94. type: {
  95. type: String,
  96. default () {
  97. return ''
  98. }
  99. },
  100. finshtype:{
  101. type: [String,Number],
  102. default () {
  103. return ''
  104. }
  105. },
  106. suggestionId:{
  107. type: [String,Number],
  108. default () {
  109. return ''
  110. }
  111. },
  112. peolist:{
  113. type: Array,
  114. default () {
  115. return []
  116. }
  117. },
  118. vxsztList:{
  119. type: Array,
  120. default () {
  121. return []
  122. }
  123. },
  124. bxlbList:{
  125. type: Array,
  126. default () {
  127. return []
  128. }
  129. },
  130. bxlb:{
  131. type: [String,Number],
  132. default () {
  133. return ''
  134. }
  135. }
  136. },
  137. data(){
  138. return{
  139. //附件
  140. option: {
  141. // 上传服务器地址,需要替换为你的接口地址
  142. url: baseUrl+'/common/upload', // 该地址非真实路径,需替换为你项目自己的接口地址
  143. // 上传附件的key
  144. name: 'file',
  145. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  146. header: {
  147. // 示例参数可删除
  148. 'Authorization': 'Bearer ' + getToken(),
  149. 'Clientid': Clientid,
  150. },
  151. // 根据你接口需求自定义body参数
  152. formData: {
  153. }
  154. },
  155. // 选择文件后是否立即自动上传,true=选择后立即上传
  156. instantly: true,
  157. // 必传宽高且宽高应与slot宽高保持一致
  158. width: '',
  159. height: '40rpx',
  160. // 限制允许上传的格式,空串=不限制,默认为空
  161. formats: 'doc,docx,xls,xlsx,ppt,txt,pdf,zip,rar,word,png,jpg,jpeg',
  162. // 文件上传大小限制
  163. size: 100,
  164. // 文件数量限制 默认10
  165. count: 5,
  166. // 文件回显列表
  167. files: new Map(),
  168. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  169. wxFiles: [],
  170. // 是否打印日志
  171. debug: false,
  172. filelist:[],
  173. filico:require('@/work/static/filico.png'),
  174. fdelimg:require('@/work/static/fjdel.png'),
  175. baseUrl:config.baseUrl,
  176. closeimg:require("@/work/static/close.png"),
  177. rimg: require('@/people/static/people/rimg.png'),
  178. headbg: require('@/service/static/service/headbg.png'),
  179. addpho: require('@/service/static/service/addpho.png'),
  180. rdelimg: require('@/service/static/service/rdel.png'),
  181. voice: require('@/service/static/service/voice.png'),
  182. syqxidx:'',
  183. datainfo:{
  184. iszc:""
  185. },
  186. sexs: [{
  187. text: '男',
  188. value: 0
  189. }, {
  190. text: '女',
  191. value: 1
  192. }],
  193. peoval:0,
  194. text:'',//文本框
  195. peoinfo:'',
  196. phofile:[],
  197. voiceflag:false,
  198. }
  199. },
  200. mounted() {
  201. this.baseUrl=baseUrl
  202. },
  203. watch:{
  204. // loanApplicationNumber(val){
  205. // this.option.formData.loanApplicationNumber=val
  206. // this.jjoption.formData.loanApplicationNumber=val
  207. // },
  208. // loanApplicationId(val){
  209. // this.option.formData.loanApplicationId=val
  210. // this.jjoption.formData.loanApplicationId=val
  211. // },
  212. type(val){
  213. // this.filelist=[];
  214. // this.shtext='';
  215. // this.isty='2';
  216. this.phofile=[];
  217. }
  218. },
  219. methods:{
  220. kaType(data, list) {
  221. return selectDictValue(list, data);
  222. },
  223. getVoiceFn(){
  224. this.voiceflag=true;
  225. },
  226. getvoiceClose(){
  227. this.voiceflag=false;
  228. },
  229. getVoice(data){
  230. this.text=data;
  231. },
  232. bindDateChange(){
  233. var val=e.detail.value;
  234. },
  235. getClose(){
  236. this.$emit('getClose')
  237. },
  238. getSure(type){
  239. var that=this;
  240. var data={}
  241. if(type=='reply'){
  242. if(!this.text){
  243. this.$toast("请输入回复内容")
  244. return
  245. }
  246. data.replyContent=this.text;
  247. if(this.filelist){
  248. data.suggestionFjList=this.filelist
  249. }
  250. }else if(type=='assign'){
  251. var peoinfo=JSON.parse(JSON.stringify(this.peoinfo))
  252. data.staffName=peoinfo.staffName;
  253. data.staffId=peoinfo.staffId;
  254. data.staffPhone=peoinfo.phoneNumber;
  255. data.staffUserId=peoinfo.userId;
  256. }else if(type=='assigncheck'){
  257. var peoinfo=JSON.parse(JSON.stringify(this.phofile))
  258. if(peoinfo.length<1){
  259. this.$toast("请上传图片")
  260. return
  261. }
  262. data.imgurl=peoinfo.join(',');
  263. }
  264. this.$emit('getSure',data)
  265. },
  266. getChose(val,ite){
  267. this.peoval=val;
  268. this.peoinfo=JSON.parse(JSON.stringify(ite))
  269. },
  270. getPreview(idx,arr){
  271. var newArr=[];
  272. arr.forEach(ite=>{
  273. var ds=this.baseUrl+ite
  274. newArr.push(ds)
  275. })
  276. uni.previewImage({
  277. urls: newArr,
  278. current:idx,
  279. success: function(data) {
  280. },
  281. fail: function(err) {
  282. }
  283. });
  284. },
  285. // 上传
  286. onuploadEnd(item,fileVal,bigType) {
  287. var newobj={}
  288. var responseText=JSON.parse(item.responseText)
  289. console.log(responseText,22)
  290. if(responseText.code==200){
  291. // if(fileVal=='qtfj'){
  292. // newobj.name=responseText.originalFilename;
  293. // }else{
  294. // newobj.name=responseText.newFileName;
  295. // }
  296. var response=responseText.data
  297. newobj.name=response.newFileName;
  298. newobj.oldName=response.originalFilename;
  299. newobj.url=response.fileName;
  300. newobj.type=fileVal;
  301. newobj.bigType=bigType;
  302. newobj.suggestionId=this.suggestionId;
  303. // newobj.loanApplicationNumber=this.loanApplicationNumber;
  304. this.filelist.push(newobj)
  305. }else{
  306. this.$toast(responseText.msg)
  307. }
  308. },
  309. getDelFj(idx){
  310. var that=this;
  311. uni.showModal({
  312. title: '确认删除',
  313. content: "是否确认删除",
  314. cancelText: '取消',
  315. confirmText: '确认',
  316. success: function(res) {
  317. if (res.confirm) {
  318. that.filelist.splice(idx,1)
  319. } else if (res.cancel) {
  320. }
  321. }
  322. });
  323. },
  324. getDown(path,name){
  325. console.log(path,name)
  326. // #ifdef APP-PLUS
  327. self.getFilePermissions(function(res){
  328. if(res==1){
  329. uni.showLoading({
  330. title: '加载中'
  331. });
  332. var url = baseUrl + path;
  333. let dtask = plus.downloader.createDownload(url, {
  334. filename: 'file://storage/emulated/0/'+baseName+'/' + name
  335. }, (d, status) => {
  336. //d为下载的文件对象
  337. if (status == 200) {
  338. uni.hideLoading();
  339. uni.showToast({
  340. icon: 'none',
  341. mask: true,
  342. title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
  343. duration: 3000,
  344. });
  345. //下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
  346. let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
  347. setTimeout(() => {
  348. plus.runtime.openFile(d.filename); //选择软件打开文件
  349. }, 1500)
  350. } else {
  351. //下载失败
  352. uni.hideLoading();
  353. plus.downloader.clear(); //清除下载任务
  354. uni.showToast({
  355. icon: 'none',
  356. mask: true,
  357. title: '下载失败,请稍后重试',
  358. });
  359. }
  360. })
  361. dtask.start();
  362. }else{
  363. uni.hideLoading();
  364. uni.showToast({
  365. title: '无法获取权限,文件下载将出错!',
  366. icon: 'none',
  367. })
  368. }
  369. })
  370. // #endif
  371. // #ifndef APP-PLUS
  372. this.getDownloader(path)
  373. // #endif
  374. },
  375. getDownloader(e){
  376. uni.showLoading({
  377. title: '加载中'
  378. });
  379. var url=baseUrl+e;
  380. let index1 = e.lastIndexOf("."); // 得到一个索引值
  381. let index2 = e.length;
  382. let type = e.substring(index1, index2);
  383. if ((type.indexOf('jpg') > -1 || type.indexOf('jpeg') > -1 || type.indexOf('png') > -1)) {
  384. uni.previewImage({
  385. current: 0,
  386. urls: [url],
  387. // background: '#ffffff'
  388. });
  389. uni.hideLoading();
  390. } else {
  391. uni.downloadFile({
  392. url: url,//文件的下载路径
  393. success(result) {
  394. uni.hideLoading()
  395. var filePath = result.tempFilePath;
  396. uni.openDocument({
  397. filePath: filePath,
  398. showMenu: true,
  399. success: function (res) {
  400. // console.log('打开文档成功');
  401. }
  402. });
  403. },
  404. fail(res) {uni.hideLoading()}
  405. })
  406. }
  407. },
  408. getDelFn(idx){
  409. var that=this;
  410. uni.showModal({
  411. title: '确认删除',
  412. content: "是否确认删除",
  413. cancelText: '取消',
  414. confirmText: '确认',
  415. success: function(res) {
  416. if (res.confirm) {
  417. that.phofile.splice(idx,1)
  418. } else if (res.cancel) {
  419. }
  420. }
  421. });
  422. },
  423. getaddImage(e){
  424. let that = this;
  425. let file =[],count=9
  426. uni.chooseImage({
  427. success:function(res){
  428. let img= res.tempFilePaths;
  429. if(img.length + file.length > count){
  430. uni.showToast({
  431. title: '最多上传'+count+'张图片',
  432. icon: 'none',
  433. duration: 2000
  434. })
  435. }else{
  436. let imglen = res.tempFilePaths.length;
  437. var fuwufile = [];
  438. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  439. that.phofile = that.phofile.concat(rs);
  440. })
  441. }
  442. }
  443. });
  444. },
  445. }
  446. }
  447. </script>
  448. <style lang="scss" scoped>
  449. // 指派
  450. .assignbox{background: #FFFFFF;border-radius: 20rpx;position: fixed;left:56rpx;right:54rpx;z-index: 10;top: 50%;transform: translateY(-50%);padding: 32rpx 38rpx 36rpx;
  451. .assbox{max-height: calc(100vh - 300rpx);overflow: auto;}
  452. .asstit{font-weight: bold;font-size: 30rpx;color: #272727;text-align: center;padding-left: 16rpx;margin-bottom: 28rpx;}
  453. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  454. image{width: 100%;height: 100%;}
  455. }
  456. .asline{border-bottom: 2rpx solid #E5E5E5;padding: 30rpx 0;margin-bottom: 40rpx;}
  457. .tabtit{font-weight: bold;font-size: 26rpx;color: #272727;line-height: 36rpx;margin-bottom: 24rpx;padding-left: 14rpx;}
  458. .asslists{display: flex;flex-wrap: wrap;
  459. .asslist{width: 252rpx;height: 76rpx;border-radius: 20rpx;border: 2rpx solid #DADADA;position: relative;display: flex;align-items: center;box-sizing: border-box;padding: 0 22rpx;margin: 0 14rpx 24rpx 14rpx;overflow: hidden;
  460. &.act{border-color: #0256FD;
  461. .altit{color: #0256FD;}
  462. }
  463. image{position: absolute;right: -2rpx;bottom: -2rpx;width: 34rpx;height: 32rpx;}
  464. .altit{font-weight: bold;font-size: 26rpx;color: #666666;flex: 1;}
  465. .altxt{font-weight: bold;font-size: 22rpx;flex: 0 0 auto;}
  466. }
  467. }
  468. // 上传图片
  469. &.pra{left: 100rpx;right: 100rpx;}
  470. .assadd{display: flex;flex-direction: column;align-items: center;justify-content: center;border-radius: 10rpx;height: 192rpx;
  471. border: 2rpx dashed #A7A7A7;box-sizing: border-box;margin-bottom: 32rpx;
  472. image{width:48rpx;height: 40rpx;margin-bottom: 16rpx;}
  473. view{font-weight: bold;font-size: 26rpx;color: #272727;}
  474. }
  475. .assimgs{display: flex;align-items: center;flex-wrap: wrap;margin-bottom: 8rpx;
  476. .assimg{width: 140rpx;height: 140rpx;position: relative;overflow: hidden;margin: 0 24rpx 24rpx 0;
  477. &:nth-of-type(3n){margin-right: 0;}
  478. .img{width: 100%;height: 100%;}
  479. .delimg{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  480. }
  481. }
  482. }
  483. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;margin-top: 40rpx;
  484. font-size: 24rpx;
  485. color: #45CB99;
  486. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  487. }
  488. // 附件
  489. .fjlists {display: flex;align-items: flex-start;justify-content: space-between;margin-bottom: 20rpx;
  490. &:last-child{margin-bottom: 0;}
  491. .imgl{width: 40rpx;height: 40rpx;display: flex;align-items: center;flex: 0 0 auto;
  492. image{width: 26rpx;height: 24rpx;}
  493. }
  494. .tit{font-size: 26rpx;color: #222327;font-weight: 500;margin-top: 4rpx;word-break: break-all;}
  495. .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;flex: 0 0 auto;
  496. image{width: 24rpx;height: 24rpx;}
  497. }
  498. .txta{color: #28C529;font-weight: 500;line-height: 40rpx;flex: 0 0 auto;margin-left: 18rpx;padding: 0 6rpx;}
  499. }
  500. .closeimg{width: 32rpx;height: 32rpx;position: absolute;bottom: -62rpx;left: 50%;margin-left: -16rpx;}
  501. </style>