123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <template>
- <a-spin :spinning="confirmLoading">
- <j-form-container :disabled="formDisabled">
- <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
- <div class="cmms-dialog-item-title">基本信息</div>
- <a-row>
- <!-- <a-col :span="12">
- <a-form-model-item label="点检内容编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentcode">
- <a-input v-model="model.contentcode" placeholder="请输入所属点检内容编号" ></a-input>
- </a-form-model-item>
- </a-col> -->
- <a-col :span="12">
- <a-form-model-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
- <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" placeholder="请选择设备" @change="handleChange"/>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item label="点检内容名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentname">
- <a-input v-model="model.contentname" placeholder="请输入所属点检内容名称" :disabled="disableds" ></a-input>
- </a-form-model-item>
- </a-col>
- <!-- <a-col :span="12">
- <a-form-model-item label="所属点检内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spotcheckcontid">
- <j-search-select-tag v-model="model.spotcheckcontid" dict="cmms_spotcheck_content,contentname,id" />
- </a-form-model-item>
- </a-col> -->
- <a-col :span="12">
- <a-form-model-item label="点检结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="result">
- <j-dict-select-tag type="list" v-model="model.result" dictCode="spotcheck_result" placeholder="请选择点检结果" @change="resultChange"/>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item :label="resultStatus == -1? '故障日期' : '点检时间'" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spotcheckdate">
- <j-date :placeholder="resultStatus == -1? '请选择故障日期':'请选择点检时间'" v-model="model.spotcheckdate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item :label="resultStatus == -1? '故障描述' : '点检描述'" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description">
- <!-- <a-input v-model="model.description" placeholder="请输入点检描述" ></a-input> -->
- <a-textarea v-model="model.description" :placeholder="resultStatus == -1?'请输入故障描述':'请输入点检描述'" :auto-size="{ minRows: 2, maxRows: 3 }" />
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item label="点检备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
- <!-- <a-input v-model="model.remark" placeholder="请输入点检备注" ></a-input> -->
- <a-textarea v-model="model.remark" placeholder="请输入点检备注" :auto-size="{ minRows: 2, maxRows: 3 }" />
- </a-form-model-item>
- </a-col>
- <a-col :span="12" v-if="resultStatus == -1">
- <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repairname">
- <span slot="label">
- 工单名称
- <a-tooltip title="点检结果为报修,需新增维修工单">
- <a-icon type="exclamation-circle" theme="filled" />
- </a-tooltip>
- </span>
- <a-input v-model="model.repairname" placeholder="请输入维修工单名称" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="12" v-if="resultStatus == -1">
- <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="priority">
- <span slot="label">
- 优先级
- <a-tooltip title="点检结果为报修,需新增维修工单">
- <a-icon type="exclamation-circle" theme="filled" />
- </a-tooltip>
- </span>
- <j-dict-select-tag v-model="model.priority" placeholder="请选择维修优先级" dictCode="repair_priority"/>
- </a-form-model-item>
- </a-col>
- <!-- <a-col :span="12">
- <a-form-model-item label="点检人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createBy">
- </a-form-model-item>
- </a-col> -->
- <a-col :span="12">
- <a-form-model-item label="故障照片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
- <j-image-upload text="上传" v-model="model.files" isMultiple></j-image-upload>
- </a-form-model-item>
- </a-col>
- </a-row>
- <div class="cmms-dialog-item-title u-flex-jab">
- <div>点检列表</div>
- <div>
- <a-button @click="allT" type="link">一键正常</a-button>
- <a-button @click="allF" type="link">一键异常</a-button>
- </div>
- </div>
- <a-table
- ref="table"
- size="middle"
- :scroll="{x:true}"
- bordered
- rowKey="itemcode"
- :columns="columns"
- :dataSource="model.cmmsSpotcheckTitemList"
- :pagination="false"
- class="j-table-force-nowrap">
- <template slot="iresult" slot-scope="text, record,index">
- <a-form-model-item :prop="'cmmsSpotcheckTitemList.'+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="'cmmsSpotcheckTitemList.'+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-form-model>
- </j-form-container>
- </a-spin>
- </template>
- <script>
- import { httpAction, getAction } from '@/api/manage'
- import { validateDuplicateValue } from '@/utils/util'
- export default {
- name: 'SpotcheckForm',
- components: {
- },
- props: {
- //表单禁用
- disabled: {
- type: Boolean,
- default: false,
- required: false
- },
- // dataList: {
- // type: Object,
- // default: function(){
- // return {} // 使用工厂函数返回默认值
- // }
- // },
- },
- data () {
- return {
- model:{
- cmmsSpotcheckTitemList: []
- },
- modelWX:{
- },
- // 单个禁填
- disableds: false,
- // 点检结果(-1为报修,1为其他结果)
- resultStatus: 1,
- labelCol: {
- xs: { span: 24 },
- sm: { span: 5 },
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 16 },
- },
- 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: 'conditions',
- },
- {
- title:'点检结果',
- align:"center",
- dataIndex: 'iresult',
- scopedSlots: { customRender: 'iresult' }
- },
- {
- title:'点检备注',
- align:"center",
- dataIndex: 'iremark',
- scopedSlots: { customRender: 'iremark' }
- }
- ],
- confirmLoading: false,
- validatorRules: {
- contentname: [
- { required: true, message: '请输入点检内容名称!'},
- ],
- equipmentid: [
- { required: true, message: '请选择设备!'},
- ],
- result: [
- { required: true, message: '请输入点检结果!'},
- ],
- description: [
- { required: true, message: '请输入点检描述/故障描述!'},
- ],
- spotcheckdate: [
- { required: true, message: '请选择点检时间!'},
- ],
- repairname: [
- { required: true, message: '请输入工单名称!'},
- ],
- priority: [
- { required: true, message: '请选择优先级!'},
- ],
- },
- url: {
- add: "/cmmsSpotcheck/cmmsSpotcheck/add",
- add2: "/cmmsRepair/cmmsRepair/add",
- edit: "/cmmsSpotcheck/cmmsSpotcheck/edit",
- queryById: "/cmmsSpotcheck/cmmsSpotcheck/queryById"
- }
- }
- },
- computed: {
- formDisabled(){
- return this.disabled
- },
- },
- created () {
- //备份model原始值
- this.modelDefault = JSON.parse(JSON.stringify(this.model));
- },
- methods: {
- add () {
- this.edit(this.modelDefault);
- this.disableds = true
- // 第二版
- // this.model = this.dataList
- // this.model.id = ""
- },
- // 监听选择的设备
- handleChange(value){
- console.log(value)
- getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoByEquipmentid/${value}`).then((res) => {
- // this.model = res.result
- this.model.contentname = res.result.contentname
- this.model.spotcheckdate = res.result.spotcheckdate
- this.model.cmmsSpotcheckTitemList = res.result.cmmsSpotcheckTitemList
- this.model.id = ""
- })
- },
- edit (record) {
- this.disableds = true
- getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoBySpotcheckid/${record.id}`).then((res) => {
- this.model = res.result
- const b = res.result.files.map((res) => {
- return res.url
- })
- this.model.files = b.join(',')
- this.visible = true;
- })
- // this.model = Object.assign({}, record);
- // this.visible = true;
- },
- submitForm () {
- const that = this;
- // 触发表单验证
- this.$refs.form.validate(valid => {
- if (valid) {
- that.confirmLoading = true;
- let httpurl = '';
- let httpurl2 = '';
- let method = '';
- if(!this.model.id){
- httpurl+=this.url.add;
- method = 'post';
- // 判断点检结果是否为报修
- if (this.resultStatus == -1) {
- console.log(99,this.model)
- this.modelWX.equipmentid = this.model.equipmentid
- // 下面两句:将带有时分秒的去掉,只传年月日
- // const time = this.model.spotcheckdate
- // this.modelWX.faultdate=time.replace(/ \d+(:\d+){2}/,'');
- this.modelWX.faultdate = this.model.spotcheckdate
- this.modelWX.faultdesc = this.model.description
- this.modelWX.repairname = this.model.repairname
- this.modelWX.priority = this.model.priority
- const c = this.model.files.split(',')
- this.modelWX.files = c.map((res) => {
- return {
- url: res
- }
- })
- console.log("00",this.modelWX)
- httpurl2+=this.url.add2;
- httpAction(httpurl2,this.modelWX,method).then((res)=>{
- if(res.success){
- that.$message.success("维修工单新增成功!");
- }else{
- that.$message.warning(res.message);
- }
- })
- }
- }else{
- httpurl+=this.url.edit;
- method = 'put';
- }
- if (this.model.files.length != 0) {
- const a = this.model.files.split(',')
- this.model.files = a.map((res) => {
- return {
- url: res
- }
- })
- }else{
- this.model.files = []
- }
- 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;
- })
- }
- })
- },
- allT() {
- this.model.cmmsSpotcheckTitemList = this.model.cmmsSpotcheckTitemList.map((res) => {
- var data = res
- data.iresult = "0"
- return data
- })
- },
- allF() {
- this.model.cmmsSpotcheckTitemList = this.model.cmmsSpotcheckTitemList.map((res) => {
- var data = res
- data.iresult = "1"
- return data
- })
- },
- // 监听点检结果
- resultChange(value) {
- if (value == 2) {
- this.resultStatus = -1
- }else{
- this.resultStatus = 1
- }
- }
- }
- }
- </script>
- <style scoped>
- @import "~@/assets/less/uStyle.less";
- </style>
|