popup.vue 15 KB

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