popup.vue 15 KB

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