jinlin
2024-02-01 2df883fcbed176f83d8d144fd007e7f72fcb54d6
web/packages/components/zt-dialog/src/zt-dialog.vue
@@ -12,11 +12,28 @@
    @close="onClose">
    <slot></slot>
    <template slot="footer">
      <el-button @click="visible = false" v-show="editAble">{{ $t('cancel') }}</el-button>
      <el-button type="primary" @click="formSubmit()" v-preventReClick v-show="editAble && hasConfirm">{{ $t('confirm')
        }}
      </el-button>
      <el-button type="info" @click="close()" v-show="!editAble">{{ $t('close') }}</el-button>
      <template v-if="isView">
        <el-button type="info" @click="close()">{{ $t('close') }}</el-button>
      </template>
      <template v-else>
        <template v-if="stepMarker && stepMarker.indexOf('first')>0">
          <el-button type="warning" @click="formSubmit('zc')">暂存</el-button>
          <el-button type="warning" @click="formSubmit('tj')" v-if="">提交
          </el-button>
        </template>
        <template v-else-if="stepMarker">
          <el-button type="warning" @click="formSubmit('zc')">暂存</el-button>
          <el-button type="warning" @click="formSubmit('bl')">办理</el-button>
        </template>
        <el-button v-else-if="hasConfirm" type="primary" @click="formSubmit('qd')" v-preventReClick>{{
          $t('confirm') }}
        </el-button>
        <el-button v-else-if="editAble" type="warning" @click="formSubmit('bc')">保存
        </el-button>
        <el-button type="info" @click="visible = false" v-if="editAble||stepMarker">{{ $t('cancel') }}</el-button>
        <el-button type="info" @click="close()" v-else>{{ $t('close') }}</el-button>
      </template>
      <slot name="footer"></slot>
    </template>
  </el-dialog>
@@ -32,23 +49,33 @@
        type: String,
        default: '1'
      },
      stepMarker: {},
      appendToBody: {
        type: Boolean,
        default: false
      },
      hasConfirm: {
        type: Boolean,
        default: true
        default: false
      },
      editAble: {
        type: Boolean,
        default: true
      },
      hasSubmit: {
        type: Boolean,
        default: false
      },
      hasSave: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        dataFormBack: null,
        visible: false
        visible: false,
        isView: false,
        //editAble: true // 是否可编辑
      }
    },
@@ -58,7 +85,7 @@
          return this.title
        } else if (!this.editAble) {
          return this.$t('view')
        } else if(this.$parent.dataForm!==undefined) {
        } else if (this.$parent.dataForm !== undefined) {
          return !this.$parent.dataForm.id ? this.$t('add') : this.$t('update')
        }
      }
@@ -68,16 +95,17 @@
    },
    methods: {
      init(id, row, isView) {
        this.isView = isView
        this.$nextTick(() => {
          // 清空表单校验
          console.log(this.$parent.$refs.dataForm,id, row, isView,'this.$parent.$refs.dataForm')
          console.log(this.$parent.$refs.dataForm, id, row, isView, 'this.$parent.$refs.dataForm')
          if (this.$parent.$refs.dataForm) { // dialog里面的form
            this.$parent.$refs.dataForm.resetFields()
          }
          this.editAble = isView !== true // 是否可编辑
          // 设置dialog父页面初始化表单
          this.$parent.dataForm = cloneDeep(this.dataFormBack)
          if (this.$parent.dataForm) {
            this.$parent.dataForm.id = id
@@ -85,6 +113,7 @@
          }
          if (this.$parent.init) {
            console.log(id, row, this.stepMarker, 'id row')
            this.$parent.init(id, row)
          }
          if (id && this.$parent.getInfo) {
@@ -94,12 +123,12 @@
        this.open()
      },
      // 表单提交
      formSubmit() {
      formSubmit(submitType) {
        let dataForm = this.$parent.$refs.dataForm
        if (dataForm) {
          dataForm.validate(async valid => {
            if (valid) {
              this.$emit('confirm')
              this.$emit('confirm', submitType)
            } else {
              this.$nextTick(() => {
                let isError = document.getElementsByClassName('is-error')
@@ -114,7 +143,7 @@
            }
          })
        } else {
          this.$emit('confirm')
          this.$emit('confirm', submitType)
        }
      },
      open() {
@@ -137,7 +166,7 @@
    /deep/ .el-dialog {
      position: fixed;
      margin-top: 0 !important;
      top:50% !important;
      top: 50% !important;
      left: 50% !important;
      transform: translate(-50%, -50%);
      width: 50%;
@@ -153,9 +182,10 @@
      width: 60%;
      position: fixed;
      margin-top: 0 !important;
      top:50% !important;
      top: 50% !important;
      left: 50% !important;
      transform: translate(-50%, -50%);
      .el-form > .el-form-item, .el-form .el-collapse-item__content > .el-form-item {
        width: 50%;
        float: left;
@@ -168,9 +198,10 @@
      width: 75%;
      position: fixed;
      margin-top: 0 !important;
      top:50% !important;
      top: 50% !important;
      left: 50% !important;
      transform: translate(-50%, -50%);
      .el-form > .el-form-item, .el-form .el-collapse-item__content > .el-form-item {
        //width: 33.33333%;
        float: left;
@@ -183,9 +214,10 @@
      width: 90%;
      position: fixed;
      margin-top: 0 !important;
      top:50% !important;
      top: 50% !important;
      left: 50% !important;
      transform: translate(-50%, -50%);
      .el-form > .el-form-item, .el-form .el-collapse-item__content > .el-form-item {
        //width: 33.33333%;
        float: left;