| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <template>
- <view class="container">
- <common-tabs :list="list" :current="current" @change="change" />
- <view class="p-top8">
- <template v-if="listData.length > 0">
- <view class="mx3 my2 p3 bg-color-white box p-relative" v-for="(item, index) in listData" :key="item.id"
- @click="handleDetail(item.id)" @longpress="showMask(item.id, $event)">
- <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" @del="handleDel(item.id)" />
- <view class="d-flex j-between border-bottom pb-2 a-center">
- <view class="text-color-b f-size-26 text-overflow">{{ item.sbNo }} ({{ item.sbName }})</view>
- <my-badge :text="statusMap[item.status]" :status="dict[item.status]" />
- </view>
- <view class="mt-2 d-flex j-between">
- <view class="text-color-3 f-size-32 f-weight-bold">{{
- item.requirementList ? item.requirementList.map(i => i.stdName).join('、') : ''
- }}</view>
- </view>
- <view class="f-size-26 text-color-6 f-weight-4 mt-2">计划执行日期:{{
- item.startTime
- }}
- </view>
- <view class="f-size-26 text-color-6 f-weight-4 mt-2">实际执行日期:{{
- item.actualStartTime
- }}
- </view>
- <view class="f-size-26 text-color-6 f-weight-4 mt-2">设备部位:{{
- item.partName
- }}
- </view>
- <view class="d-flex j-end edit-box">
- <!-- 与 PC 端 CheckJob 保持一致:仅未执行(1)可接收 -->
- <view class="text-color-3 f-size-32 edit" v-if="item.status === 1 && !startFlag">
- <view @click.stop="handleExecute(item)">开始</view>
- </view>
- <!-- 与 PC 端 CheckJob 保持一致:仅执行中(2)可执行/完成 -->
- <!-- <view class="text-color-3 f-size-32 edit" v-if="item.status === 2 && !startFlag">
- <view @click.stop="handleFinish(item)">执行</view>
- </view> -->
- <view class="text-color-3 f-size-32 edit" v-if="item.status === 2">
- <view @click.stop="submit(item)">完成</view>
- </view>
- </view>
- </view>
- <view class="py3">
- <u-loadmore :status="status" />
- </view>
- </template>
- <template v-else>
- <view class="empty">
- <u-empty text="暂无数据" mode="list"></u-empty>
- </view>
- </template>
- </view>
- <!-- <view class="p-fixed d-flex j-around a-center footer">
- <view class="main-color-bg text-color-white common" @tap="handleStart">{{ nums }}</view>
- </view> -->
- </view>
- </template>
- <script>
- import BaseTool from '../../utils/tool'
- export default {
- data() {
- return {
- list: [],
- current: 1,
- sbId: '',
- nums: '开始计时',
- // 加载更多
- status: 'loadmore',
- page: 1,
- timer: null,
- limit: 10,
- type: 1,
- filter: -1,
- searchType: null,
- startFlag: false,
- loadMore: true,
- listData: [],
- periodMap: null,
- statusMap: null,
- sbStatusMap: null,
- dict: null,
- maskId: 0,
- statusList: null,
- receiveOvertime: null,
- timeFlag: null
- }
- },
- onPullDownRefresh() {
- // 请求结束取消刷新
- this.page = 1
- this.loadMore = true
- this.listData = []
- this.initData()
- uni.stopPullDownRefresh()
- },
- onReachBottom() {
- if (this.loadMore) {
- this.page++
- this.initData()
- }
- },
- onLoad(options) {
- this.sbId = options.sbId
- this.filter = options.filter
- this.searchType = options.searchType
- this.timeFlag = options.timeFlag
- if (uni.getStorageSync('check-job-start-' + this.sbId)) {
- this.startFlag = true
- var oldTime = uni.getStorageSync('check-job-start-' + this.sbId)
- // 设置计时:
- var hour, minute, second // 时 分 秒
- hour = minute = second = 0 // 初始化
- var millisecond = 0 // 毫秒
- var ms = Math.abs(new Date() - new Date(oldTime))
- // 两个日期相减得到毫秒数 1s=1000ms
- var s = ms / 1000 // 毫秒转为秒
- console.log(s)
- hour = Math.floor(s / 3600) // 小时
- minute = Math.floor((s % 3600) / 60) // 分
- second = Math.floor(s % 60) // 秒
- console.log(hour, minute, second)
- this.timer = setInterval(() => {
- millisecond = millisecond + 50
- if (millisecond >= 1000) {
- millisecond = 0
- second = second + 1
- }
- if (second >= 60) {
- second = 0
- minute = minute + 1
- }
- if (minute >= 60) {
- minute = 0
- hour = hour + 1
- }
- // console.log("-------"+hour+'时'+minute+'分'+second+'秒');
- this.nums = hour + '时' + minute + '分' + second + '秒'
- }, 50)
- }
- this.periodMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
- this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_STATUS)
- this.sbStatusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_SB_STATUS)
- this.list = [{ label: '全部', value: '' }].concat(this.$DictCache.getChildrenList(this.$DictCache.TYPE.CHECK_JOB_STATUS))
- this.dict = this.$DictCache.COLOR.CHECK_JOB_STATUS
- },
- onShow() {
- this.listData = []
- this.initData()
- },
- onHide() {
- this.maskId = 0
- },
- methods: {
- showMask(id, e) {
- this.maskId = id
- // #ifdef H5
- e.preventDefault()
- // #endif
- },
- handleDel(id) {
- const that = this
- const params = []
- params.push(id)
- uni.showModal({
- title: '提示',
- content: '您确认删除吗?',
- success: res => {
- if (res.confirm) {
- this.$Http.deleteCheckJobs(params).then(res => {
- uni.showToast({ title: '删除成功' })
- this.page = 1
- this.loadMore = true
- this.listData = []
- this.initData()
- })
- } else if (res.cancel) {
- }
- }
- })
- },
- // 详情
- handleDetail(id) {
- // if (index == 0) {
- // uni.navigateTo({
- // url: '../maintain-add/maintain-add'
- // });
- // } else {
- // uni.navigateTo({
- // url: '../maintain-detail/maintain-detail'
- // });
- // }
- if (this.maskId !== 0) {
- return (this.maskId = 0)
- }
- uni.navigateTo({
- url: '/pages/maintain-detail/maintain-detail?detailId=' + id + '&filter=' + this.filter + '&searchType=' + this.searchType
- })
- },
- handleExecute(item) {
- this.$Http.execute(item).then(res => {
- item.status = this.$DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING
- this.current = this.$DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING
- this.change(this.current, this.current)
- uni.showToast({ title: '已开始,请及时完成任务' })
- })
- },
- handleFinish(item) {
- uni.navigateTo({
- url: '/pages/maintain-add/maintain-add?detailId=' + item.id + '&filter=' + this.filter + '&searchType=' + this.searchType
- })
- },
- // tab
- change(index, value) {
- this.current = index
- console.log(index)
- this.statusList = null
- this.receiveOvertime = null
- if (index === 0) {
- this.type = ''
- } else if (value === 4) {
- // 已过期与 PC 端逾期页(PollingCheckJobOverTime)一致:receiveOvertime + 不限状态
- this.type = null
- this.statusList = []
- this.receiveOvertime = true
- } else {
- this.type = value
- }
- this.page = 1
- this.loadMore = true
- this.listData = []
- this.initData()
- },
- handleStart() {
- clearInterval(this.timer)
- uni.showToast({
- title: '已开始计时'
- })
- this.startFlag = true
- uni.setStorageSync('check-job-start-' + this.sbId, this.$BaseTool.Date.formatter(new Date(), BaseTool.Date.PICKER_NORM_DATETIME_PATTERN))
- var hour, minute, second // 时 分 秒
- hour = minute = second = 0 // 初始化
- var millisecond = 0 // 毫秒
- this.timer = setInterval(() => {
- millisecond = millisecond + 50
- if (millisecond >= 1000) {
- millisecond = 0
- second = second + 1
- }
- if (second >= 60) {
- second = 0
- minute = minute + 1
- }
- if (minute >= 60) {
- minute = 0
- hour = hour + 1
- }
- // console.log("-------"+hour+'时'+minute+'分'+second+'秒');
- this.nums = hour + '时' + minute + '分' + second + '秒'
- }, 50)
- },
- // 提交
- submit(item) {
- console.log(22)
- uni.navigateTo({
- url: `/pages/maintain/finish?id=${item.id}&standardId=${item.standardId}`
- })
- // item.actualStartTime = uni.getStorageSync('check-job-start');
- // item.status = 3
- // this.$Http.finishJob(item).then((res) => {
- // uni.showToast({
- // title: '已完成'
- // });
- // this.initData();
- // });
- },
- initData() {
- const that = this
- that.status = 'loading'
- this.$Http
- .getCheckJobPage({
- pageNum: this.page,
- pageSize: this.limit,
- type: 2,
- filter: this.filter,
- searchType: this.searchType,
- sbId: this.sbId,
- status: this.type,
- receiveOvertime: this.receiveOvertime,
- // 与 PC 端 CheckJob 一致:默认只查未执行/执行中/已完成,不含已过期(4)
- statusList: this.statusList === null ? [1, 2, 3] : this.statusList,
- timeFlag: this.timeFlag,
- // 与 PC 端 CheckJob loadData 参数保持一致
- mineFlag: false,
- record: this.type === 3 ? 1 : null
- })
- .then(res => {
- const data = res.data.rows
- if (data && data.length > 0 && data.length < that.limit) {
- that.status = 'nomore'
- that.loadMore = false
- } else if (data.length == that.limit) {
- that.status = 'loadmore'
- } else {
- that.status = 'nomore'
- }
- that.listData = [...that.listData, ...data]
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #f4f4f4;
- }
- .box {
- padding-right: 0;
- border-radius: 20rpx;
- }
- .edit-box {
- padding: 0 30rpx;
- margin-top: 40rpx;
- .edit {
- padding: 8rpx 40rpx;
- border: 1px solid #ddd;
- border-radius: 20rpx;
- font-size: 26rpx;
- color: #666;
- margin-left: 30rpx;
- }
- }
- .text-overflow {
- width: 60%;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .container {
- padding-bottom: 100rpx;
- .footer {
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #fff;
- z-index: 10000;
- }
- .title {
- border-bottom: 1rpx solid #f4f4f4;
- }
- .img {
- width: 100rpx;
- height: 100rpx;
- }
- .p-fixed {
- border-top: 1rpx solid #f4f4f4;
- height: 100rpx;
- .common {
- padding: 15rpx 200rpx;
- border-radius: 30rpx;
- background-color: #0082ff;
- color: #fff;
- }
- }
- }
- </style>
|