popup.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. }else if(type=='assigncheck'){
  256. var peoinfo=JSON.parse(JSON.stringify(this.phofile))
  257. if(peoinfo.length<1){
  258. this.$toast("请上传图片")
  259. return
  260. }
  261. data.imgurl=peoinfo.join(',');
  262. }
  263. this.$emit('getSure',data)
  264. },
  265. getChose(val,ite){
  266. this.peoval=val;
  267. this.peoinfo=JSON.parse(JSON.stringify(ite))
  268. },
  269. getPreview(idx,arr){
  270. var newArr=[];
  271. arr.forEach(ite=>{
  272. var ds=this.baseUrl+ite
  273. newArr.push(ds)
  274. })
  275. uni.previewImage({
  276. urls: newArr,
  277. current:idx,
  278. success: function(data) {
  279. },
  280. fail: function(err) {
  281. }
  282. });
  283. },
  284. // 上传
  285. onuploadEnd(item,fileVal,bigType) {
  286. var newobj={}
  287. var responseText=JSON.parse(item.responseText)
  288. if(responseText.code==200){
  289. // if(fileVal=='qtfj'){
  290. // newobj.name=responseText.originalFilename;
  291. // }else{
  292. // newobj.name=responseText.newFileName;
  293. // }
  294. newobj.name=responseText.newFileName;
  295. newobj.oldName=responseText.originalFilename;
  296. newobj.url=responseText.fileName;
  297. newobj.type=fileVal;
  298. newobj.bigType=bigType;
  299. newobj.suggestionId=this.suggestionId;
  300. // newobj.loanApplicationNumber=this.loanApplicationNumber;
  301. this.filelist.push(newobj)
  302. }else{
  303. this.$toast(responseText.msg)
  304. }
  305. },
  306. getDelFj(idx){
  307. var that=this;
  308. uni.showModal({
  309. title: '确认删除',
  310. content: "是否确认删除",
  311. cancelText: '取消',
  312. confirmText: '确认',
  313. success: function(res) {
  314. if (res.confirm) {
  315. that.filelist.splice(idx,1)
  316. } else if (res.cancel) {
  317. }
  318. }
  319. });
  320. },
  321. getDown(path,name){
  322. console.log(path,name)
  323. // #ifdef APP-PLUS
  324. self.getFilePermissions(function(res){
  325. if(res==1){
  326. uni.showLoading({
  327. title: '加载中'
  328. });
  329. var url = baseUrl + path;
  330. let dtask = plus.downloader.createDownload(url, {
  331. filename: 'file://storage/emulated/0/'+baseName+'/' + name
  332. }, (d, status) => {
  333. //d为下载的文件对象
  334. if (status == 200) {
  335. uni.hideLoading();
  336. uni.showToast({
  337. icon: 'none',
  338. mask: true,
  339. title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
  340. duration: 3000,
  341. });
  342. //下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
  343. let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
  344. setTimeout(() => {
  345. plus.runtime.openFile(d.filename); //选择软件打开文件
  346. }, 1500)
  347. } else {
  348. //下载失败
  349. uni.hideLoading();
  350. plus.downloader.clear(); //清除下载任务
  351. uni.showToast({
  352. icon: 'none',
  353. mask: true,
  354. title: '下载失败,请稍后重试',
  355. });
  356. }
  357. })
  358. dtask.start();
  359. }else{
  360. uni.hideLoading();
  361. uni.showToast({
  362. title: '无法获取权限,文件下载将出错!',
  363. icon: 'none',
  364. })
  365. }
  366. })
  367. // #endif
  368. // #ifndef APP-PLUS
  369. this.getDownloader(path)
  370. // #endif
  371. },
  372. getDownloader(e){
  373. uni.showLoading({
  374. title: '加载中'
  375. });
  376. var url=baseUrl+e;
  377. let index1 = e.lastIndexOf("."); // 得到一个索引值
  378. let index2 = e.length;
  379. let type = e.substring(index1, index2);
  380. if ((type.indexOf('jpg') > -1 || type.indexOf('jpeg') > -1 || type.indexOf('png') > -1)) {
  381. uni.previewImage({
  382. current: 0,
  383. urls: [url],
  384. // background: '#ffffff'
  385. });
  386. uni.hideLoading();
  387. } else {
  388. uni.downloadFile({
  389. url: url,//文件的下载路径
  390. success(result) {
  391. uni.hideLoading()
  392. var filePath = result.tempFilePath;
  393. uni.openDocument({
  394. filePath: filePath,
  395. showMenu: true,
  396. success: function (res) {
  397. // console.log('打开文档成功');
  398. }
  399. });
  400. },
  401. fail(res) {uni.hideLoading()}
  402. })
  403. }
  404. },
  405. getDelFn(idx){
  406. var that=this;
  407. uni.showModal({
  408. title: '确认删除',
  409. content: "是否确认删除",
  410. cancelText: '取消',
  411. confirmText: '确认',
  412. success: function(res) {
  413. if (res.confirm) {
  414. that.phofile.splice(idx,1)
  415. } else if (res.cancel) {
  416. }
  417. }
  418. });
  419. },
  420. getaddImage(e){
  421. let that = this;
  422. let file =[],count=9
  423. uni.chooseImage({
  424. success:function(res){
  425. let img= res.tempFilePaths;
  426. if(img.length + file.length > count){
  427. uni.showToast({
  428. title: '最多上传'+count+'张图片',
  429. icon: 'none',
  430. duration: 2000
  431. })
  432. }else{
  433. let imglen = res.tempFilePaths.length;
  434. var fuwufile = [];
  435. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  436. that.phofile = that.phofile.concat(rs);
  437. })
  438. }
  439. }
  440. });
  441. },
  442. }
  443. }
  444. </script>
  445. <style lang="scss" scoped>
  446. // 指派
  447. .assignbox{background: #FFFFFF;border-radius: 20rpx;position: fixed;left:56rpx;right:54rpx;z-index: 10;top: 50%;transform: translateY(-50%);padding: 32rpx 38rpx 36rpx;
  448. .assbox{max-height: calc(100vh - 300rpx);overflow: auto;}
  449. .asstit{font-weight: bold;font-size: 30rpx;color: #272727;text-align: center;padding-left: 16rpx;margin-bottom: 28rpx;}
  450. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  451. image{width: 100%;height: 100%;}
  452. }
  453. .asline{border-bottom: 2rpx solid #E5E5E5;padding: 30rpx 0;margin-bottom: 40rpx;}
  454. .tabtit{font-weight: bold;font-size: 26rpx;color: #272727;line-height: 36rpx;margin-bottom: 24rpx;padding-left: 14rpx;}
  455. .asslists{display: flex;flex-wrap: wrap;
  456. .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;
  457. &.act{border-color: #0256FD;
  458. .altit{color: #0256FD;}
  459. }
  460. image{position: absolute;right: -2rpx;bottom: -2rpx;width: 34rpx;height: 32rpx;}
  461. .altit{font-weight: bold;font-size: 26rpx;color: #666666;flex: 1;}
  462. .altxt{font-weight: bold;font-size: 22rpx;flex: 0 0 auto;}
  463. }
  464. }
  465. // 上传图片
  466. &.pra{left: 100rpx;right: 100rpx;}
  467. .assadd{display: flex;flex-direction: column;align-items: center;justify-content: center;border-radius: 10rpx;height: 192rpx;
  468. border: 2rpx dashed #A7A7A7;box-sizing: border-box;margin-bottom: 32rpx;
  469. image{width:48rpx;height: 40rpx;margin-bottom: 16rpx;}
  470. view{font-weight: bold;font-size: 26rpx;color: #272727;}
  471. }
  472. .assimgs{display: flex;align-items: center;flex-wrap: wrap;margin-bottom: 8rpx;
  473. .assimg{width: 140rpx;height: 140rpx;position: relative;overflow: hidden;margin: 0 24rpx 24rpx 0;
  474. &:nth-of-type(3n){margin-right: 0;}
  475. .img{width: 100%;height: 100%;}
  476. .delimg{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  477. }
  478. }
  479. }
  480. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;margin-top: 40rpx;
  481. font-size: 24rpx;
  482. color: #45CB99;
  483. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  484. }
  485. // 附件
  486. .fjlists {display: flex;align-items: flex-start;justify-content: space-between;margin-bottom: 20rpx;
  487. &:last-child{margin-bottom: 0;}
  488. .imgl{width: 40rpx;height: 40rpx;display: flex;align-items: center;flex: 0 0 auto;
  489. image{width: 26rpx;height: 24rpx;}
  490. }
  491. .tit{font-size: 26rpx;color: #222327;font-weight: 500;margin-top: 4rpx;word-break: break-all;}
  492. .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;flex: 0 0 auto;
  493. image{width: 24rpx;height: 24rpx;}
  494. }
  495. .txta{color: #28C529;font-weight: 500;line-height: 40rpx;flex: 0 0 auto;margin-left: 18rpx;padding: 0 6rpx;}
  496. }
  497. .closeimg{width: 32rpx;height: 32rpx;position: absolute;bottom: -62rpx;left: 50%;margin-left: -16rpx;}
  498. </style>