|
@@ -0,0 +1,386 @@
|
|
|
+<template>
|
|
|
+ <a-spin :spinning="confirmLoading">
|
|
|
+ <j-form-container :disabled="formDisabled">
|
|
|
+ <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
|
|
+ <a-row class="inspect-order-layout">
|
|
|
+ <a-col :span="8" class="inspect-tree">
|
|
|
+ <a-tree
|
|
|
+ :tree-data="treeData"
|
|
|
+ show-icon
|
|
|
+ default-expand-all
|
|
|
+ showLine
|
|
|
+ :selected-keys="selectedKeys"
|
|
|
+ :replaceFields="replaceFields"
|
|
|
+ @select="onSelect"
|
|
|
+ >
|
|
|
+ <a-icon slot="switcherIcon" type="down" />
|
|
|
+ <a-icon slot="smile" type="smile-o" />
|
|
|
+ <a-icon slot="meh" type="smile-o" />
|
|
|
+ <template slot="custom" slot-scope="{ selected }">
|
|
|
+ <a-icon :type="selected ? 'frown' : 'frown-o'" />
|
|
|
+ </template>
|
|
|
+ </a-tree>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="16" class="itemList-table">
|
|
|
+ <a-button @click="handleFeedback">提交反馈</a-button>
|
|
|
+ <a-table
|
|
|
+ ref="table"
|
|
|
+ size="middle"
|
|
|
+ :scroll="{x:true}"
|
|
|
+ bordered
|
|
|
+ rowKey="id"
|
|
|
+ :columns="columns"
|
|
|
+ :dataSource="model.itemList"
|
|
|
+ :pagination="false"
|
|
|
+ class="j-table-force-nowrap">
|
|
|
+ <template slot="iresult" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'itemList.'+index+'.iresult'" :rules="validatorRules.iresult" style="margin-bottom: 0px;">
|
|
|
+ <a-radio-group name="radioGroup" v-model="record.iresult">
|
|
|
+ <a-radio value="0">
|
|
|
+ 正常
|
|
|
+ </a-radio>
|
|
|
+ <a-radio value="1">
|
|
|
+ 异常
|
|
|
+ </a-radio>
|
|
|
+ </a-radio-group>
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
+ <template slot="iremark" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'itemList.'+index+'.iremark'" :rules="validatorRules.iremark" style="margin-bottom: 0px;">
|
|
|
+ <a-input v-model="record.iremark" placeholder="请输入点检备注"></a-input>
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
+ </a-table>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form-model>
|
|
|
+ </j-form-container>
|
|
|
+ </a-spin>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+const treeData = [
|
|
|
+ {
|
|
|
+ title: '测试123456',
|
|
|
+ key: '1111111111111',
|
|
|
+ type: '巡检路线',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ title: '测试巡检点的修改NO1',
|
|
|
+ key: '12223333333',
|
|
|
+ type: '巡检点',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ title: '半自动立钻Z5180C',
|
|
|
+ key: '55555555555',
|
|
|
+ type: '巡检内容',
|
|
|
+ ItemList: [
|
|
|
+ // 巡检项相关信息
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '测试巡检点的修改NO2',
|
|
|
+ key: '456293324552',
|
|
|
+ type: '巡检点',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ title: '半自动立钻Z5180D',
|
|
|
+ key: '1335633666666',
|
|
|
+ type: '巡检内容',
|
|
|
+ ItemList: [
|
|
|
+ // 巡检项相关信息
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+ import { httpAction, getAction, putAction } from '@/api/manage'
|
|
|
+ import { validateDuplicateValue } from '@/utils/util'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: 'InspectForm',
|
|
|
+ components: {
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ //表单禁用
|
|
|
+ disabled: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ required: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ model: {
|
|
|
+ itemList: []
|
|
|
+ },
|
|
|
+ labelCol: {
|
|
|
+ xs: { span: 24 },
|
|
|
+ sm: { span: 5 },
|
|
|
+ },
|
|
|
+ wrapperCol: {
|
|
|
+ xs: { span: 24 },
|
|
|
+ sm: { span: 16 },
|
|
|
+ },
|
|
|
+ confirmLoading: false,
|
|
|
+ validatorRules: {
|
|
|
+ result: [
|
|
|
+ { required: true, message: '请输入点检结果!'},
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ url: {
|
|
|
+ add: "/cmmsInspect/cmmsInspect/add",
|
|
|
+ edit: "/cmmsInspect/cmmsInspect/edit",
|
|
|
+ queryById: "/cmmsInspect/cmmsInspect/queryById",
|
|
|
+ queryTreeById: "/cmmsInspect/cmmsInspect/queryTreeById",
|
|
|
+ queryItemByCountId: "/cmmsInspect/cmmsInspect/queryItemByCountId",
|
|
|
+ feedback: "/cmmsInspect/cmmsInspect/feedback",
|
|
|
+ },
|
|
|
+ treeData: [],
|
|
|
+ selectedKeys: [], // (受控)设置选中的树节点
|
|
|
+ replaceFields: {
|
|
|
+ children:'children',
|
|
|
+ title:'title',
|
|
|
+ key:'id'
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ // {
|
|
|
+ // title: '#',
|
|
|
+ // dataIndex: '',
|
|
|
+ // key:'rowIndex',
|
|
|
+ // width:60,
|
|
|
+ // align:"center",
|
|
|
+ // customRender:function (t,r,index) {
|
|
|
+ // return parseInt(index)+1;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ title:'巡检项编号',
|
|
|
+ align:"center",
|
|
|
+ dataIndex: 'itemcode'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:'巡检项名称',
|
|
|
+ align:"center",
|
|
|
+ dataIndex: 'itemname'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:'标准',
|
|
|
+ align:"center",
|
|
|
+ dataIndex: 'inspectionstandards',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:'巡检结果',
|
|
|
+ align:"center",
|
|
|
+ dataIndex: 'iresult',
|
|
|
+ scopedSlots: { customRender: 'iresult' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title:'巡检备注',
|
|
|
+ align:"center",
|
|
|
+ dataIndex: 'iremark',
|
|
|
+ scopedSlots: { customRender: 'iremark' }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ formDisabled(){
|
|
|
+ return this.disabled
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ //备份model原始值
|
|
|
+ this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ add () {
|
|
|
+ this.edit(this.modelDefault);
|
|
|
+ },
|
|
|
+ edit (record) {
|
|
|
+ // this.model = Object.assign({}, record);
|
|
|
+ this.visible = true;
|
|
|
+ this.confirmLoading = true
|
|
|
+ // getAction(this.url.queryById, {id: record.id}).then((res) => {
|
|
|
+ // console.log(res)
|
|
|
+ // this.model = res.result
|
|
|
+ // // console.log(res.result.planList)
|
|
|
+ // var planList = res.result.planList
|
|
|
+ // var orderData = []
|
|
|
+ // if(planList.length>0){
|
|
|
+ // for (let p = 0; p < planList.length; p++) {
|
|
|
+ // // 巡检路线
|
|
|
+ // const planItem = planList[p];
|
|
|
+ // planItem.children = []
|
|
|
+ // if(planItem.inspectLineVo){
|
|
|
+ // for (let s = 0; s < planItem.inspectLineVo.detailList.length; s++) {
|
|
|
+ // // 巡检点
|
|
|
+ // const spotItem = planItem.inspectLineVo.detailList[s];
|
|
|
+ // spotItem.children = []
|
|
|
+ // if(spotItem.inspectContentList){
|
|
|
+ // for (let i = 0; i < spotItem.inspectContentList.length; i++) {
|
|
|
+ // const contentItem = spotItem.inspectContentList[i];
|
|
|
+ // console.log(spotItem, contentItem)
|
|
|
+ // // 巡检内容数据
|
|
|
+ // if(contentItem){
|
|
|
+ // var contentNode = {
|
|
|
+ // key: contentItem.id,
|
|
|
+ // title: contentItem.equipmentname,
|
|
|
+ // slots: {
|
|
|
+ // icon: 'smile',
|
|
|
+ // },
|
|
|
+ // inspectTcontentItemList: contentItem.inspectTcontentItemList
|
|
|
+ // }
|
|
|
+ // spotItem.children.push(contentNode)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // 巡检点数据
|
|
|
+ // var spotNode = {
|
|
|
+ // key: spotItem.id,
|
|
|
+ // title: spotItem.contentname,
|
|
|
+ // slots: {
|
|
|
+ // icon: 'smile',
|
|
|
+ // },
|
|
|
+ // children: spotItem.children,
|
|
|
+ // }
|
|
|
+ // planItem.children.push(spotNode)
|
|
|
+ // }
|
|
|
+ // // 路线数据
|
|
|
+ // var planNode = {
|
|
|
+ // key: planItem.inspectLineVo.id,
|
|
|
+ // title: planItem.inspectLineVo.linename,
|
|
|
+ // slots: {
|
|
|
+ // icon: planItem.tasktype? 'smile': 'smile',
|
|
|
+ // },
|
|
|
+ // children: planItem.children,
|
|
|
+ // }
|
|
|
+ // orderData.push(planNode)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // console.log(orderData)
|
|
|
+ // this.treeData = orderData
|
|
|
+ // // if(planList.length>0){
|
|
|
+ // // planList.map(item => {
|
|
|
+ // // var spotList = item.detailList
|
|
|
+ // // if(spotList.length > 0){
|
|
|
+ // // spotList.map(spot => {
|
|
|
+ // // var
|
|
|
+ // // return {
|
|
|
+ // // key: item.id,
|
|
|
+ // // title: item.linename,
|
|
|
+ // // slots: {
|
|
|
+ // // icon: 'smile',
|
|
|
+ // // },
|
|
|
+ // // children: item.inspectLineVo,
|
|
|
+ // // }
|
|
|
+ // // })
|
|
|
+ // // }
|
|
|
+ // // return {
|
|
|
+ // // key: item.id,
|
|
|
+ // // title: item.linename,
|
|
|
+ // // slots: {
|
|
|
+ // // icon: 'smile',
|
|
|
+ // // },
|
|
|
+ // // children: item.inspectLineVo,
|
|
|
+ // // }
|
|
|
+ // // })
|
|
|
+ // // }
|
|
|
+ // this.confirmLoading = false
|
|
|
+ // })
|
|
|
+ getAction(this.url.queryTreeById, {id: record.id}).then((res) => {
|
|
|
+ console.log(res)
|
|
|
+ this.model = res.result
|
|
|
+ // this.model.itemList = []
|
|
|
+ this.treeData = res.result.children
|
|
|
+ this.confirmLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSelect(selectedKeys, info) {
|
|
|
+ // 二次点击树节点时selectedKeys为空,直接return中断执行
|
|
|
+ if (selectedKeys.length === 0) return
|
|
|
+ this.selectedKeys = selectedKeys
|
|
|
+ // console.log('selected', selectedKeys, info);
|
|
|
+ // console.log(info.selectedNodes[0].data.props.inspectTcontentItemList)
|
|
|
+ var props = info.selectedNodes[0].data.props
|
|
|
+ if(props.type === '巡检内容'){
|
|
|
+ this.model.itemList = props.inspectTcontentItemList
|
|
|
+ this.$forceUpdate()
|
|
|
+ // this.getItemList(props.id)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getItemList(id){
|
|
|
+ getAction(this.url.queryItemByCountId, {countId: id, inspectId: this.model.id}).then((res) => {
|
|
|
+ console.log(res)
|
|
|
+ this.model.itemList = res.result
|
|
|
+ console.log(this.model)
|
|
|
+ this.$forceUpdate()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleFeedback(){
|
|
|
+ console.log(this.model.itemList)
|
|
|
+ this.confirmLoading = true
|
|
|
+ putAction(this.url.feedback, this.model.itemList).then((res) => {
|
|
|
+ if(res.success){
|
|
|
+ this.$message.success(res.message);
|
|
|
+ this.edit(this.model)
|
|
|
+ }else{
|
|
|
+ this.$message.warning(res.message);
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.confirmLoading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submitForm () {
|
|
|
+ const that = this;
|
|
|
+ // 触发表单验证
|
|
|
+ this.$refs.form.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ that.confirmLoading = true;
|
|
|
+ let httpurl = '';
|
|
|
+ let method = '';
|
|
|
+ if(!this.model.id){
|
|
|
+ httpurl+=this.url.add;
|
|
|
+ method = 'post';
|
|
|
+ }else{
|
|
|
+ httpurl+=this.url.edit;
|
|
|
+ method = 'put';
|
|
|
+ }
|
|
|
+ httpAction(httpurl,this.model,method).then((res)=>{
|
|
|
+ if(res.success){
|
|
|
+ that.$message.success(res.message);
|
|
|
+ that.$emit('ok');
|
|
|
+ }else{
|
|
|
+ that.$message.warning(res.message);
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ that.confirmLoading = false;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+<style lang="less" scoped>
|
|
|
+ .inspect-order-layout{
|
|
|
+ height: calc(100vh - 150px);
|
|
|
+ overflow: hidden;
|
|
|
+ .inspect-tree{
|
|
|
+ height: calc(100vh - 150px);
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+ .itemList-table{
|
|
|
+ height: calc(100vh - 150px);
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|