TblWorkTimeForm.vue 4.0 KB
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-table ref="table" size="middle" bordered rowKey="id" class="j-table-force-nowrap" :scroll="{ x: true }"
          :columns="columns" :dataSource="res" :pagination="false">
        </a-table>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
import { queryGxOne } from '../../../api/manage'

  export default {
    name: 'TblWorkTimeForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        res:[],
        model:{
         },
         columns: [
        {
          title: '工序',
          align: 'center',
          dataIndex: 'workingProcedure',
        },
        {
          title: '承接人',
          align: 'center',
          dataIndex: 'undertaker',
        },
        {
          title: '工时',
          align: 'center',
          dataIndex: 'workHours',
        },

        {
          title: '派发时间',
          align: 'center',
          dataIndex: 'dispatchTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '派发人',
          align: 'center',
          dataIndex: 'dispatchRen',
        },
        {
          title: '验收时间',
          align: 'center',
          dataIndex: 'yanTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '验收人',
          align: 'center',
          dataIndex: 'yanRen',
        },
        {
          title: '验收结果',
          align: 'center',
          dataIndex: 'yanResult',
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'notes',
        },
      ],
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/work_time/tblWorkTime/add",
          edit: "/work_time/tblWorkTime/edit",
          queryById: "/work_time/tblWorkTime/queryById",
          querygxone:"/production/tblProductionPlan/querygxone"
        }
      }
    },
    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;
      },
      queryGxOne(salaryMonth,name){
        queryGxOne(this.url.querygxone,this.model).then((res) =>{
          this.res=res.result
        })
      },
      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>