popup.vue 15 KB

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