guoshilong
2022-10-08 830ce15ad9894bdfd442ecd3e8051bd0cd79836b
维修工单增加开始维修和完成维修功能,添加维修材料申请功能
7 files modified
3 files added
258 ■■■■■ changed files
api/inventory/inventory.js 8 ●●●●● patch | view | raw | blame | history
api/inventory/invreqRecord.js 9 ●●●●● patch | view | raw | blame | history
components/evan-upload/evan-upload.vue 2 ●●● patch | view | raw | blame | history
manifest.json patch | view | raw | blame | history
pages.json 6 ●●●●● patch | view | raw | blame | history
pages/eventgm/eventsReported.vue 13 ●●●● patch | view | raw | blame | history
pages/inventory/materialRequire.vue 108 ●●●●● patch | view | raw | blame | history
pages/repairsorder/detail.vue 49 ●●●●● patch | view | raw | blame | history
pages/repairsorder/list.vue 60 ●●●●● patch | view | raw | blame | history
pages/taskinfo/detail.vue 3 ●●●● patch | view | raw | blame | history
api/inventory/inventory.js
New file
@@ -0,0 +1,8 @@
import http from '@/http/api.js'
export const getInvList = () => {
  return http.request({
    url: '/inventory/inventory/inv-list',
    method: 'get',
  })
}
api/inventory/invreqRecord.js
New file
@@ -0,0 +1,9 @@
import http from '@/http/api.js'
export const add = (data) => {
  return http.request({
    url: '/invreqRecord/invreqRecord/submit',
    method: 'post',
    data:data
  })
}
components/evan-upload/evan-upload.vue
@@ -243,7 +243,7 @@
        // 图片的预览的键(默认 thumbnail)
        imgCoverKey: {
            type: String,
            default: 'thumbnail'
            default: 'http://dev.jxpskj.com:9000/zhnc/upload/20220923/66713609576bbaa24a2f87145a3134c6.jpeg'
        },
        // 图片限制
        imgLimit: {
manifest.json
pages.json
@@ -60,6 +60,12 @@
                "navigationBarTitleText": "工单详情",
                "enablePullDownRefresh": false
            }
        },{
            "path": "pages/inventory/materialRequire",
            "style": {
                "navigationBarTitleText": "维修材料申请",
                "enablePullDownRefresh": false
            }
        }
    ],
    "globalStyle": {
pages/eventgm/eventsReported.vue
@@ -40,7 +40,13 @@
            </u-action-sheet> -->
            
            <u-form-item label-position="top" label-width="25%" label="图片上传:">
                <evan-upload ref="evanUpload" :imgLimit="4" :options="uploadOption" @on-upload="onUpload"></evan-upload>
                <evan-upload ref="evanUpload"
                :usePreview="true"
                :imgLimit="4"
                :options="uploadOption"
                @on-upload="onUpload"
                @on-pre-video="onPreVideo"
            ></evan-upload>
            </u-form-item>
            
            <u-form-item label-position="top" label="备注:">
@@ -123,6 +129,7 @@
        this.getHeader()
    },
    methods:{
        //获取头部
        getHeader(){
            let accessToken = uni.getStorageSync('accessToken');
            var myHeader = {}
@@ -187,6 +194,7 @@
            this.form.sourceText = this.sourceList[index].text
            this.form.source = this.sourceList[index].value
        },
        //表单提交
        submit(){
            this.$refs.uForm.validate(valid => {
                if (valid) {
@@ -226,7 +234,8 @@
                    e.thumbnail = res.data.link
                })
            }
        },
        onPreVideo(res){
        }
    }
};
pages/inventory/materialRequire.vue
New file
@@ -0,0 +1,108 @@
<template>
    <view class="container">
        <u-form :model="form" ref="uForm" :rules="rules">
            <u-form-item label-width="20%" label="申请材料:" prop="inventoryId">
                <u-input v-model="form.inventoryText" type="select" @click="showInventory = true" placeholder="请选择申请材料"/>
            </u-form-item>
            <u-action-sheet
                v-model="showInventory"
                :list="inventoryList"
                title="请选择事件类型"
                @click="inventorySelect"
            >
            </u-action-sheet>
            <u-form-item label-width="20%" label="申请数量:" prop="reqNum">
                <u-input v-model="form.reqNum" placeholder="请输入申请数量"/>
            </u-form-item>
            <u-form-item label-position="top" label="备注:">
                <u-input v-model="form.remark" type="textarea" />
            </u-form-item>
        </u-form>
        <view class="submitBtn">
            <u-button @click="submit">申请</u-button>
        </view>
    </view>
</template>
<script>
    import {getInvList} from "@/api/inventory/inventory.js"
    import {add} from "@/api/inventory/invreqRecord.js"
    export default {
        onReady() {
            //设置表单验证规则
            this.$refs.uForm.setRules(this.rules);
        },
        data(){
            return{
                form:{
                    inventoryText:"",
                    inventoryId:"",
                    reqNum:"",
                    remark:"",
                },
                rules:{
                    inventoryId:[{
                        required:true,
                        message:'请选择申请材料',
                        trigger:'blur'
                    }],
                    reqNum:[{
                        pattern:/^[1-9]\d*$/,
                        transform(value) {
                            return String(value);
                        },
                        required:true,
                        message:'请输入正确的申请数量',
                        trigger:'blur'
                    }],
                },
                showInventory:false,
                inventoryList:[],
            }
        },
        created() {
            this.getInventoryList()
        },
        methods:{
            getInventoryList(){
                getInvList().then(res=>{
                    if(res.code ==200){
                        res.data.forEach(e=>{
                            this.inventoryList.push({
                                text:e.name,
                                key:e.id
                            })
                        })
                    }
                })
            },
            inventorySelect(index){
                this.form.inventoryText = this.inventoryList[index].text
                this.form.inventoryId = this.inventoryList[index].key
            },
            submit(){
                this.$refs.uForm.validate(valid => {
                    if(valid){
                        add(this.form).then(res=>{
                            if(res.code == 200){
                                uni.navigateBack({
                                    delta:1
                                })
                            }
                        })
                    }
                })
            }
        }
    }
</script>
<style scoped>
    .container{
        padding: 20px;
    }
</style>
pages/repairsorder/detail.vue
@@ -44,7 +44,9 @@
                </span>
            </view>
            <view class="once-c">
                <u-button type="success">开始任务</u-button>
                <u-button v-if="repairsorderData.state == 1" type="success" @click="startRepair(repairsorderData)">开始维修</u-button>
                <u-button v-if="repairsorderData.state == 2" type="success" @click="finishRepair(repairsorderData)">完成维修</u-button>
                <u-button v-if="repairsorderData.state!=3" type="error" @click="materialRequire">材料申请</u-button>
            </view>
        </view>
    </view>
@@ -52,7 +54,7 @@
<script>
    import {
        getDetail
        getDetail,update
    } from "@/api/repairsorder/repairsorder"
    export default {
        data() {
@@ -86,6 +88,9 @@
            getTaskinfoDetail() {
                var _that = this
                getDetail(_that.id).then(res => {
                    if(res.data.picUrls.length==0){
                        res.data.picUrls == null
                    }
                    _that.repairsorderData = res.data;
                    if (_that.repairsorderData.latitude && _that.repairsorderData.longitude) {
                        _that.latitude = _that.repairsorderData.latitude
@@ -99,6 +104,46 @@
                    }
                })
            },
            //开始维修
            startRepair(item){
                uni.showModal({
                    title:"提示",
                    content:"是否开始维修?",
                    success:(res)=> {
                        if(res.confirm){
                            item.state = '2'
                            update(item).then(res=>{
                                if(res.code == 200){
                                    this.getTaskinfoDetail()
                                }
                            })
                        }
                    }
                })
            },
            //维修完成
            finishRepair(item){
                uni.showModal({
                    title:"提示",
                    content:"是否完成维修?",
                    success:(res)=> {
                        if(res.confirm){
                            item.state = '3'
                            update(item).then(res=>{
                                if(res.code == 200){
                                    this.getTaskinfoDetail()
                                }
                            })
                        }
                    }
                })
            },
            //维修材料申请
            materialRequire(){
                uni.navigateTo({
                    url: '/pages/inventory/materialRequire'
                })
            }
        },
        onLoad: function(options) {
pages/repairsorder/list.vue
@@ -29,11 +29,12 @@
                            </view>
                        </view>
                        <view class="onve-right">
                            <u-button class='greens' size="mini" v-if="current == 0">开始维修
                            <u-button class='greens' size="mini" v-if="current == 0" @click="startRepair(item)">开始维修
                            </u-button>
                            <u-button class='greens' size="mini" v-if="current == 1">完成维修
                            <u-button class='greens' size="mini" v-if="current == 1" @click="finishRepair(item)">完成维修
                            </u-button>
                            <u-button class='o-r-down' plain type="error" size="mini" v-if="current != 2" @click="materialRequire">材料申请
                            </u-button>
                        </view>
                    </view>
@@ -47,7 +48,7 @@
<script>
    import {
        getList
        getList,update
    } from "@/api/repairsorder/repairsorder";
    export default {
        data() {
@@ -76,6 +77,9 @@
                repairsorderList: null
            }
        },
        onShow() {
            this.getList()
        },
        created() {
            this.getList()
        },
@@ -92,6 +96,11 @@
                getList(this.page.currentPage, this.page.pageSize, this.query).then(res => {
                    const data = res.data;
                    this.page.total = data.total;
                    data.records.forEach(e=>{
                        if(e.picUrls.length==0){
                            e.picUrls = null
                        }
                    })
                    this.repairsorderList = data.records;
                })
            },
@@ -110,8 +119,49 @@
                uni.navigateTo({
                    url: '/pages/repairsorder/detail?id=' + id
                })
            },
            //开始维修
            startRepair(item){
                uni.showModal({
                    title:"提示",
                    content:"是否开始维修?",
                    success:(res)=> {
                        if(res.confirm){
                            item.state = '2'
                            update(item).then(res=>{
                                if(res.code == 200){
                                    this.page.currentPage = 1
                                    this.getList()
            }
                            })
                        }
                    }
                })
            },
            //维修完成
            finishRepair(item){
                uni.showModal({
                    title:"提示",
                    content:"是否结束任务?",
                    success:(res)=> {
                        if(res.confirm){
                            item.state = '3'
                            update(item).then(res=>{
                                if(res.code == 200){
                                    this.page.currentPage = 1
                                    this.getList()
                                }
                            })
                        }
                    }
                })
            },
            //维修材料申请
            materialRequire(){
                uni.navigateTo({
                    url: '/pages/inventory/materialRequire'
                })
            }
        }
    }
</script>
pages/taskinfo/detail.vue
@@ -53,8 +53,7 @@
            </view>
            <view class="once-c">
                <u-button v-if="taskinfoData.state == 0" type="success" @click="startTask(taskinfoData)">开始任务</u-button>
                <u-button v-if="taskinfoData.state == 1" type="success" @click="finishTask(taskinfoData)">完成任务
                </u-button>
                <u-button v-if="taskinfoData.state == 1" type="success" @click="finishTask(taskinfoData)">完成任务</u-button>
                <u-button v-if="taskinfoData.state == 1" type="error" @click="goToEventsReported">事件上报</u-button>
            </view>
        </view>