<template> 
 | 
  <GlobalWindow 
 | 
    :title="title" 
 | 
    :visible.sync="visible" 
 | 
    :confirm-working="isWorking" 
 | 
    @confirm="confirm" 
 | 
  > 
 | 
    <el-form :model="form" ref="form" :rules="rules"> 
 | 
      <el-form-item label="报废原因" prop="remark"> 
 | 
        <el-input 
 | 
          type="textarea" 
 | 
          :autosize="{minRows: 4}" 
 | 
          v-model="form.remark" 
 | 
          maxlength="100" 
 | 
          placeholder="请输入报废原因,100字以内" 
 | 
          v-trim 
 | 
        /> 
 | 
      </el-form-item> 
 | 
    </el-form> 
 | 
  </GlobalWindow> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
import BaseOpera from '@/components/base/BaseOpera' 
 | 
import GlobalWindow from '@/components/common/GlobalWindow' 
 | 
import { updateStatus } from '@/api/ext/appliancesExt' 
 | 
export default { 
 | 
  name: 'OperaAppliancesExtWindow', 
 | 
  extends: BaseOpera, 
 | 
  components: { GlobalWindow }, 
 | 
  data () { 
 | 
    return { 
 | 
      // 表单数据 
 | 
      form: { 
 | 
        ids: '', 
 | 
        remark: '' 
 | 
      }, 
 | 
      // 验证规则 
 | 
      rules: { 
 | 
        remark: [ 
 | 
          { required: true, message: '请输入报废原因', trigger: 'blur' }, 
 | 
          { max: 100, message: '不能超过100字', trigger: 'blur' } 
 | 
        ] 
 | 
      } 
 | 
    } 
 | 
  }, 
 | 
  created () { 
 | 
    this.config({ 
 | 
      api: '/ext/appliancesExt', 
 | 
      'field.id': 'id' 
 | 
    }) 
 | 
  }, 
 | 
  methods: { 
 | 
    confirm () { 
 | 
      this.$refs.form.validate((valid) => { 
 | 
        if (!valid) { 
 | 
          return 
 | 
        } 
 | 
        const query = 'ids=' + this.form.ids + '&remark=' + this.form.remark 
 | 
        this.isWorking = true 
 | 
        updateStatus(query) 
 | 
          .then(res => { 
 | 
            console.log(res) 
 | 
            this.$refs.form.resetFields() 
 | 
            this.visible = false 
 | 
            this.$message.success('报废成功') 
 | 
            this.$emit('success') 
 | 
          }) 
 | 
          .catch(err => { 
 | 
            this.$message.error(err) 
 | 
          }) 
 | 
          .finally(() => { 
 | 
            this.isWorking = false 
 | 
          }) 
 | 
      }) 
 | 
    } 
 | 
  } 
 | 
} 
 | 
</script> 
 |