warranty.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view class="car">
  3. <view class="cartop">
  4. <!-- <view class="topa flexc">
  5. <image :src="reset" class="resetimg" @click="getReset"></image>
  6. <picker mode="date" @change='bindDateChangea'>
  7. <view class="chekt flexc">
  8. <view>{{cxrq|| "选择日期"}}</view>
  9. <image :src="up"></image>
  10. </view>
  11. </picker>
  12. <view class="search flexc">
  13. <image :src="search"></image>
  14. <input placeholder="请输入房号进行搜索" v-model="text"/>
  15. <view class="btn" @click="getConfirm">搜索</view>
  16. </view>
  17. </view> -->
  18. <view class="tabtop flexc">
  19. <view class="tabt" :class="tabval==ite.val?'act':''" v-for="(ite,idx) in tablist" :key="idx" @click="getTabFn(ite.val)">{{ite.tit}}</view>
  20. </view>
  21. </view>
  22. <!-- 列表 -->
  23. <view class="carlists">
  24. <car-list :datainfo="list" :bxlbList="bxlbList" :bxztList="bxztList" :wtdt="wtdt" type='warranty' @getDetail="getDetail" @getDelFn="getDelFn" @getAssignFn="getAssignFn" @getCheckFn="getCheckFn"></car-list>
  25. </view>
  26. <pop-up :type="type" @getClose='getClose' :bxlbList="bxlbList" :bxlb="maintenanceCategory" :vxsztList="vxsztList" :peolist="peolist" :finshtype='repairStatus' @getSure="getSure"></pop-up>
  27. <loading></loading>
  28. </view>
  29. </template>
  30. <script>
  31. import config from '@/config'
  32. const baseUrl = config.baseUrl
  33. import popUp from "@/service/components/popup/popup.vue"
  34. import carList from "@/service/components/car/list.vue"
  35. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  36. import {repairList,repairDel,repairPut,repairAssign} from "@/api/work/service.js"
  37. import {stafflistNoPage} from "@/api/work/people.js"
  38. import {getDictionaryFn} from "@/api/system/user.js"
  39. export default{
  40. components:{carList,popUp},
  41. data(){
  42. return{
  43. reset:require('@/car/static/car/reset.png'),
  44. search:require('@/car/static/car/search.png'),
  45. up:require('@/car/static/car/up.png'),
  46. cxrq:"",
  47. text:'',
  48. list:[],
  49. pageSize: 10,
  50. pageNum: 1,
  51. reachflag: true,
  52. wtdt:'',
  53. tabval:'-1',
  54. tablist:[{tit:'全部报修',val:-1}],
  55. bxztList:[],
  56. bxlbList:[],
  57. vxsztList:[],
  58. peolist:[],
  59. maintenanceCategory:'',
  60. type:'',
  61. repairId:'',
  62. staffId:'',
  63. staffUserId:'',
  64. repairStatus:'',//维修状态
  65. userId:this.$store.state.user.userId
  66. }
  67. },
  68. onUnload() {
  69. uni.$off('repairList')
  70. },
  71. onLoad: function() {
  72. uni.$on('repairList',(res)=>{
  73. this.getrefreshData()
  74. })
  75. this.init()
  76. this.getDataFn();
  77. this.getstafflistNoPage()
  78. },
  79. // 上拉触底加载更多触发事件
  80. onReachBottom() {
  81. if (this.reachflag) {
  82. this.pageNum++
  83. this.getDataFn()
  84. }
  85. },
  86. methods:{
  87. checkPermi, checkRole,
  88. getAssignFn(data){
  89. this.type='assign';
  90. var info=JSON.parse(JSON.stringify(data))
  91. this.repairId=info.repairId;
  92. this.maintenanceCategory=info.maintenanceCategory;
  93. },
  94. getCheckFn(data){
  95. this.type='assigncheck';
  96. var info=JSON.parse(JSON.stringify(data))
  97. this.repairId=info.repairId;
  98. this.staffId=info.staffId;
  99. this.repairStatus=info.repairStatus;
  100. },
  101. getClose(){
  102. this.type='';
  103. this.repairId='';
  104. this.maintenanceCategory='';
  105. },
  106. init(){
  107. // 报修状态
  108. getDictionaryFn('repair_status').then(res=>{
  109. if(res.code==200){
  110. this.bxztList = res.data.map(v => {
  111. var obj={
  112. tit: v.dictLabel,
  113. val: v.dictValue
  114. }
  115. this.tablist.push(obj)
  116. return {
  117. dictLabel: v.dictLabel,
  118. dictValue: v.dictValue
  119. }
  120. })
  121. }
  122. })
  123. // 报修类别
  124. getDictionaryFn('baoxiutype').then(res=>{
  125. if(res.code==200){
  126. this.bxlbList = res.data.map(v => {
  127. return {
  128. dictLabel: v.dictLabel,
  129. dictValue: v.dictValue
  130. }
  131. })
  132. }
  133. })
  134. // 维修师状态
  135. getDictionaryFn('technician_status').then(res=>{
  136. if(res.code==200){
  137. this.vxsztList = res.data.map(v => {
  138. return {
  139. dictLabel: v.dictLabel,
  140. dictValue: v.dictValue
  141. }
  142. })
  143. }
  144. })
  145. },
  146. getstafflistNoPage(){
  147. var patams={
  148. staffCategory:'repair'
  149. }
  150. stafflistNoPage(patams).then(res=>{
  151. if(res.code==200){
  152. this.peolist=res.rows;
  153. }
  154. })
  155. },
  156. time() {
  157. var date = new Date();
  158. var y = date.getFullYear();
  159. var m = date.getMonth() + 1;
  160. var d = date.getDate();
  161. var h = date.getHours();
  162. var min = date.getMinutes();
  163. var s = date.getSeconds();
  164. var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  165. var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  166. '0' + s) : s);
  167. var kaTime = yearStr + ' ' + timeStr;
  168. return kaTime
  169. },
  170. getSure(data){
  171. var type=this.type;
  172. var that=this;
  173. var ite=JSON.parse(JSON.stringify(data))
  174. if(type=='assign'){
  175. ite.repairId=this.repairId;
  176. repairAssign(ite).then(res=>{
  177. if(res.code==200){
  178. that.$toast("指派成功")
  179. setTimeout(function(){
  180. that.type='';
  181. that.getrefreshData()
  182. },1500)
  183. }
  184. })
  185. }else if(type=='assigncheck'){
  186. var params={};
  187. params.repairId=this.repairId;
  188. params.staffId=this.staffId;
  189. if(this.repairStatus==2){//上门拍照
  190. params.repairStatus=3;
  191. params.visitPhoto=ite.imgurl;
  192. params.visitTime=this.time();
  193. }else{//结束拍照
  194. params.repairStatus=4;
  195. params.completionTime=this.time();
  196. params.completionPhoto=ite.imgurl;
  197. }
  198. repairPut(params).then(res=>{
  199. if(res.code==200){
  200. that.$toast("操作成功")
  201. setTimeout(function(){
  202. that.type='';
  203. that.getrefreshData()
  204. },1500)
  205. }
  206. })
  207. }
  208. },
  209. getDelFn(data){
  210. var that=this;
  211. repairDel(data).then(res=>{
  212. if(res.code==200){
  213. this.$toast("删除成功");
  214. setTimeout(function(){
  215. that.getrefreshData()
  216. },1500)
  217. }
  218. })
  219. },
  220. getDetail(id){
  221. this.$tab.navigateTo("/service/pages/service/warrantydetail?id="+id)
  222. },
  223. getConfirm(){
  224. this.getrefreshData()
  225. },
  226. getReset(){
  227. this.cxrq='';
  228. this.text='';
  229. this.getrefreshData()
  230. },
  231. getrefreshData(){
  232. this.pageNum=1;
  233. this.list=[];
  234. this.reachflag=true;
  235. this.getDataFn()
  236. },
  237. getTabFn(val){
  238. this.tabval=val;
  239. this.getrefreshData()
  240. },
  241. bindDateChangea(e){
  242. var val=e.detail.value;
  243. this.cxrq=val;
  244. },
  245. getDataFn(){
  246. var params={
  247. pageSize:this.pageSize,
  248. pageNum: this.pageNum,
  249. }
  250. if(this.tabval!=-1){
  251. params.repairStatus=this.tabval
  252. }
  253. if(checkPermi(['wuYe:repair:repairlist'])){
  254. params.staffUserId=this.userId
  255. }
  256. repairList(params).then(res=>{
  257. if(res.code==200){
  258. if (res.rows.length < this.pageSize) {
  259. this.reachflag = false
  260. this.wtdt = '到底了~';
  261. } else {
  262. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  263. if (num < res.total) {
  264. this.reachflag = true
  265. this.wtdt = ''
  266. } else {
  267. this.reachflag = false
  268. this.wtdt = '到底了~';
  269. }
  270. }
  271. var newArr=JSON.parse(JSON.stringify(res.rows))
  272. if(newArr&&newArr.length){
  273. newArr.forEach(ite=>{
  274. if(ite.repairImages){
  275. ite.repairImages=ite.repairImages.split(',')
  276. }
  277. if(ite.visitPhoto){
  278. ite.visitPhoto=ite.visitPhoto.split(',')
  279. }
  280. if(ite.completionPhoto){
  281. ite.completionPhoto=ite.completionPhoto.split(',')
  282. }
  283. })
  284. }
  285. console.log(newArr)
  286. if (this.pageNum == 1) {
  287. this.list = newArr;
  288. } else {
  289. this.list = this.list.concat(newArr)
  290. }
  291. }else{
  292. this.$toast(res.msg)
  293. }
  294. })
  295. },
  296. }
  297. }
  298. </script>
  299. <style>
  300. page{background: #F3F3F0;}
  301. </style>
  302. <style lang="scss" scoped>
  303. .car{padding: 146rpx 0 0rpx;}
  304. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  305. .topa{padding: 20rpx ;
  306. .resetimg{width: 36rpx;height: 36rpx;margin-right: 24rpx;flex: 0 0 auto;}
  307. .chekt{min-width: 180rpx;
  308. view{font-weight: 500;font-size: 26rpx;color: #272727;flex: 1;}
  309. image{width: 24rpx;height: 16rpx;margin-left: 18rpx;flex: 0 0 auto;}
  310. }
  311. .search{flex: 1;margin-left: 16rpx;height: 64rpx;background: #EEEEEE;border-radius: 32rpx;border: 2rpx solid #E6E6E6;padding-left: 24rpx;box-sizing: border-box;
  312. image{width: 32rpx;height: 34rpx;margin-right: 22rpx;flex: 0 0 auto;}
  313. input{flex: 1;font-size: 26rpx;color: #272727;}
  314. .btn{width: 100rpx;height: 64rpx;background: #3565ED;border-radius: 32rpx;flex: 0 0 auto;font-weight: bold;text-align: center;line-height: 64rpx;
  315. font-size: 26rpx;
  316. color: #FFFFFF;}
  317. }
  318. }
  319. .tabtop{padding-bottom: 40rpx;padding-top: 26rpx;
  320. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx; flex:1;text-align: center;
  321. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  322. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  323. }
  324. }
  325. }
  326. }
  327. .carlists{padding: 0 18rpx;}
  328. </style>