projectSubmissionDialog.vue 3.03 KB
<template>
  <div>
    <el-dialog
      :title="dialogForm.title"
      :visible.sync="dialogForm.dialogVisible"
      width="30%"
      @close="handleClose">
      <el-row>
        <el-form :model="dialogForm" ref="dialogForm" :rules="rules">
          <el-form-item :label="dialogForm.label" prop="textarea">
            <el-input
              type="textarea"
              :autosize="{ minRows: 4, maxRows:5}"
              placeholder="请输入内容"
              v-model="dialogForm.textarea">
            </el-input>
          </el-form-item>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleSubmit('dialogForm')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { submitData } from '@/api/projectSubmission'
export default {
  name: "projectSubmissionDialog",
  data(){
    return {
      dialogForm:{
        dialogVisible:false,
        title:'入库',
        textarea:'',
        label:'入库说明:',
        fProjectId:'',
        fEventType:''
      },
      rules:{
        textarea:[
          { required: true, message: '请填写入库说明', trigger: 'blur' }
        ]
      }
    }
  },
  methods:{
    open(type,row){
      console.log('打印type',type);
      console.log('打印row',row);
      this.dialogType = type;
      this.dialogForm.fProjectId = row.id_;
      this.dialogForm.dialogVisible = true;
      switch (type){
        case 'rk':
          this.dialogForm.title = '入库';
          this.dialogForm.label ='入库说明:';
          this.dialogForm.fEventType = 'ruku';
          break;
        case 'zf':
          this.dialogForm.label = '作废说明:';
          this.dialogForm.title = '作废';
          this.dialogForm.fEventType = 'zuofei';
          break;
        case 'xmjz':
          this.dialogForm.title = '项目进展';
          this.dialogForm.label ='本次项目进展说明:';
          this.dialogForm.fEventType = 'xiangmujinzhan';
          break;
        case 'zf':
          this.dialogForm.label = '出库说明:';
          this.dialogForm.title = '出库';
          this.dialogForm.fEventType = 'chuku';
          break;
      }
    },
    handleSubmit(formName){
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          let params ={
            fProjectId:this.dialogForm.fProjectId,
            fEventType:this.dialogForm.fEventType,
            fProgressStatus:this.dialogForm.textarea
          }
          await submitData(params).then((res)=>{
            console.log('打印res',res);
            if(res.code == 200){
              this.$emit('handleRefresh');
            }
            this.dialogForm.dialogVisible = false;
          })

        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleClose(){
      this.$refs.dialogForm.resetFields();
      this.dialogForm.dialogVisible = false;
    },
  }
}
</script>

<style scoped>

</style>