ts_aimz/pages/copyright/repair/repair.js

291 lines
8.2 KiB
JavaScript
Raw Normal View History

2025-05-08 08:57:38 +08:00
// pages/copyright/repair/repair.js
import ProApi from '../../../net/api/projectApi'
import {
previewUrl
}
from '../../../net/http.js'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
keywords: '',
pageData: {
page: 1,
rows: 10,
projName: '',
type: '',
correctionType: '',
applyStatus: ''
},
msgShow: false,
msgHint: '',
msgType: 'error',
loadingState: 'loading',
listRefreshTrig: false,
isLoadMore: false,
hasMore: true,
repairList: [], //开票记录
typeList: [{
title: '一次补正',
value: 'CORRECTION1'
}, {
title: '二次补正',
value: 'CORRECTION2'
}],
selectType: '',
kindList: [{
value: 'CODE',
title: '代码'
}, {
title: '操作手册',
value: 'MANUAL'
}, {
title: '全部',
value: 'ALL'
}],
selectKind: '',
stateList: [{
title: '待审核',
value: 'PENDING'
}, {
title: '已通过',
value: 'APPROVED'
}, {
title: '未通过',
value: 'REJECTED'
}, {
title: '已取消',
value: 'CANCELED'
}],
selectState: '',
buttons: [{
text: '关闭'
}],
showHint: false,
approveImgs: [],
approveTime: '',
approveDesc: '',
preUrl: previewUrl,
approveStatus: false, //是否显示编辑提示
slideBtns: app.globalData.cancelEditBtns
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.setNavigationBarTitle({
title: '补正项目',
})
wx.setNavigationBarColor({
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色
animation: { // 可选项
duration: 500,
timingFunc: 'easeIn'
}
})
this.doRefreshList()
},
chooseType(e) {
const value = e.currentTarget.dataset.value
this.setData({
selectType: value == this.data.selectType ? '' : value
})
this.doRefreshList()
},
chooseKind(e) {
const value = e.currentTarget.dataset.value
this.setData({
selectKind: value == this.data.selectKind ? '' : value
})
this.doRefreshList()
},
chooseState(e) {
const value = e.currentTarget.dataset.value
this.setData({
selectState: value == this.data.selectState ? '' : value
})
this.doRefreshList()
},
inputKeywords(e) {
this.setData({
keywords: e.detail.value
})
},
//清除搜索内容
clearSearch() {
const _self = this
_self.setData({
keywords: ''
})
_self.doRefreshList()
},
//发起搜索
doSearchKeyWord() {
const _self = this
_self.doRefreshList()
},
doRefreshList() {
console.log('正在刷新...')
const _self = this
_self.setData({
listRefreshTrig: true,
loadingState: 'loading',
hasMore: true,
'pageData.page': 1,
'pageData.projName': _self.data.keywords,
'pageData.type': _self.data.selectType,
'pageData.correctionType': _self.data.selectKind,
'pageData.applyStatus': _self.data.selectState,
isLoadMore: false
})
_self.doGetRepairList(true)
},
doLoadMore() {
//判断是否正在加载中 与是否存在更多数据
const _self = this
if (_self.data.isLoadMore || !_self.data.hasMore) {
return
}
_self.setData({
isLoadMore: true,
'pageData.page': ++_self.data.pageData.page,
'pageData.projName': _self.data.keywords,
'pageData.type': _self.data.selectType,
'pageData.correctionType': _self.data.selectKind,
'pageData.applyStatus': _self.data.selectState,
})
_self.doGetRepairList(false)
},
//加载列表
doGetRepairList(isRefresh) {
const _self = this
_self.setData({
repairList: isRefresh ? [] : _self.data.repairList,
loadingState: isRefresh ? 'loading' : ''
})
ProApi.doGetMineRepairList(_self.data.pageData)
.then(res => {
console.log(res)
var status = 'success'
status = res.rows && res.rows.length > 0 ? 'success' : 'empty'
_self.setData({
loadingState: isRefresh ? status : '',
repairList: _self.data.repairList.concat(res.rows),
listRefreshTrig: false,
isLoadMore: false
})
_self.setData({
hasMore: _self.data.repairList.length < res.total
})
}, err => {
_self.setData({
loadingState: 'error',
listRefreshTrig: false,
isLoadMore: false,
hasMore: true
})
})
},
show(e) {
console.log('显示', e)
//判断状态
const _self = this
const value = e.currentTarget.dataset.value
const id = e.currentTarget.id
if (value.applyStatus == 'APPROVED' || value.applyStatus == 'CANCELED') {
//通过 或 取消 后不能撤销
const item = _self.selectComponent(`#${id}`)
if (item) {
item.setData({
show: false
})
}
}
},
slideButtonTap(e) {
const index = e.detail.index
const item = e.currentTarget.dataset.value
console.log(e)
if (index == 0) {
//取消
this.showCancel(item)
}
},
//取消
showCancel(item) {
const _self = this
wx.showLoading({
title: '取消中...',
})
ProApi.doCancelProrepair(item.projCorrectionApplyId)
.then(res => {
wx.hideLoading()
_self.setData({
msgType: 'success',
msgHint: '撤销成功',
msgShow: true
})
_self.doRefreshList()
})
.catch(err => {
wx.hideLoading()
_self.setData({
msgType: 'error',
msgHint: err.msg ? err.msg : '撤销失败,请稍后重试',
msgShow: true
})
})
},
//显示凭证与未通过原因
showReason(e) {
const item = e.currentTarget.dataset.value
const _self = this
item.correctionVoucherFileKVs.map(value => {
value.url = _self.data.preUrl + value.key
return value
})
_self.setData({
approveImgs: item.correctionVoucherFileKVs,
approveTime: item.gmtReview,
approveDesc: item.reviewReason,
approveStatus: item.applyStatus == 'APPROVED' ? false : true,
showHint: true
})
},
//预览图片
previewImg(e) {
const _self = this
const current = e.currentTarget.dataset.value
const url = []
_self.data.approveImgs.forEach(item => url.push(item.url))
console.log(url)
wx.previewImage({
urls: url,
current: current
})
},
//下载文件
downloadFile(e) {
const item = e.currentTarget.dataset.value
},
closeHint(e) {
this.setData({
approveImgs: [],
approveTime: '',
approveDesc: '',
showHint: false,
approveStatus: false
})
},
//去申请补正
applyRepair() {
wx.navigateTo({
url: '/pages/copyright/applyRepair/applyRepair',
})
}
})