index.vue 4.24 KB
Newer Older
wangdanlei's avatar
wangdanlei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
<template>
  <div class="dee-page">
    <div class="full-border-content">
      <dee-static-cmp
        ref="form"
        :key="key"
        :cmp-options="searchLayout"
        :default-data="defaultData"
        :on-form-event-hander="onFormEventHander"
        :basic-data="detailForm"
        model-name="ExtECM"
        @loaded="loading=false"
        @refreshForm="refreshForm"
        @updateForm="updateForm"
      >
        <div slot="fromOrg">
          <from-org v-model="form.fromOrg" :form-value="form" />
        </div>
        <div slot="extECMActionItems">
          <extECM-actionItems ref="extaction" :form-value="form" />
        </div>
        <div slot="reference">
          <reference ref="reference" :reference="form" @on-reference="handleReference" />
        </div>
      </dee-static-cmp>
    </div>
  </div>
</template>
<script>
import fromOrg from '../common/fromOrg'
import extECMActionItems from '../common/extECMActionItems'
import reference from '../common/reference'
import { post } from '@/utils/http'
export default {
  name: 'AddEcm',
  components: { fromOrg, extECMActionItems, reference },
  data() {
    const that = this
    return {
      key: '',
      form: {},
      defaultData: {
        // creator: {
        //   userName: localStorage.getItem('user'),
        //   userId: localStorage.getItem('userId')
        // }
      },
      detailForm: {},
      searchLayout: {
        typeName: 'ExtECM',
        value: 'defaultCreate'
      },
      onFormEventHander: {
        'on-submit': () => {
          that.submitFun(that.$refs['form'].propForm)
        },
        'on-cancel': () => {
          that.cancelFun()
        }
      }
    }
  },
  mounted() {
    this.judgeRoute()
  },
  methods: {
    judgeRoute() {
      if (this.$route.query.hasOwnProperty('replay')) {
        this.$set(this.detailForm, 'id', this.$route.query.replay)
        this.$set(this.detailForm, 'subTypeName', this.$route.query.subTypeName)
        this.defaultData = {
          creator: {
            userName: localStorage.getItem('user'),
            userId: localStorage.getItem('userId')
          },
          replyEcm: this.$route.query.number
        }
      } else {
        this.defaultData = {
          creator: {
            userName: localStorage.getItem('user'),
            userId: localStorage.getItem('userId')
          }
        }
      }
    },
    refreshForm(form) {
      this.form = form
    },
    updateForm(form) {
      const acheForm = {
        itemNumber: '',
        reference: '',
        discussion: '',
        extECMActionItems: [],
        objFileLinks: [],
        creator: {
          userName: localStorage.getItem('user'),
          userId: localStorage.getItem('userId')
        },
        fromOrg: {},
        fromOrgId: '',
        carbonCopy: '',
        fromDept: '',
        toDept: '',
        concerned: '',
        distributeFrom: '',
        distributeTo: '',
        replyTypeCode: '',
        toOrg: form.fromOrg,
        replyEcm: this.$route.query.number
      }
      this.form = form
      this.form = Object.assign(this.form, acheForm)
    },
    submitFun(form) {
      const dealForm = JSON.parse(JSON.stringify(form))
      if (dealForm.dxContext) {
        dealForm.dxContext = {
          id: dealForm.dxContext.id,
          name: dealForm.dxContext.name,
          subTypeName: dealForm.dxContext.subTypeName
        }
      }

      if (this.form.replyEcm) {
        delete dealForm.id
        delete dealForm.creator
        delete dealForm.creatorId
        delete dealForm.modifier
        delete dealForm.modifierId
        delete dealForm.createTime
        delete dealForm.modifyTime
        delete dealForm.releaseFile
      }
      const params = {
        ...dealForm,
        reference: this.$refs.reference.value,
        extECMActionItems: this.$refs.extaction.ajaxTableData
      }
      post('/ExtECM/recursion', params).then(res => {
        this.cancelFun()
        this.$utils.showMessageSuccess('保存成功')
      })
    },

    cancelFun(isRef = false) {
      this.$store.dispatch('tagsView/delVisitedView', { path: '/addEcm' })
      this.$router.push({
        path: '/ecm'
      })
    },
    handleReference(val) {
      this.$set(this.form, 'reference', val)
    }
  }
}
</script>
<style lang="scss">

</style>