zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<template>
  <div class="search-form">
    <SectionTitle :title="'出资机构清单'"></SectionTitle>
    <div class="middle-button" v-if="isEdit">
      <el-button
        style="margin-bottom:20px"
        type="primary"
        icon="el-icon-circle-plus-outline"
        size="small"
        @click="addRecord"
      >新增</el-button>
    </div>
 
    <CommTable
      :loading="loading"
      :isAutoIndex="true"
      :list="list"
      :maxHeight="530"
      :header="tableHeader"
      @doAction="doAction"
      @updateValue="updateTableValue"
      ref="waterTable"
    ></CommTable>
 
    <div v-if="dialogList">
      <el-dialog :visible.sync="dialogList" :modal-append-to-body="false" width="850px">
        <OutFundCheckDialog
          :title="dialogTitle"
          :records="tempRecord"
          :serialNo="query.serialNo"
          @close="dialogList = false"
          @toShowSucc="toShowSucc"
        ></OutFundCheckDialog>
      </el-dialog>
    </div>
 
    <Dialog
      v-model="isShowDel"
      title="删除确认"
      :buttons="[{ text: '取消' }, { text: '确定', type: 'primary' }]"
      @handleClick="clickDel"
      :contentText="`请确认是否需要删除该数据 ?`"
    ></Dialog>
  </div>
</template>
 
<script>
import { mapMutations } from 'vuex'
import CommForm from '@/components/CommForm'
import CommTable from '@/components/CommTable'
import SectionTitle from '@/components/SectionTitle'
import Dialog from '@/components/Dialog'
import OutFundCheckDialog from '@/components/tabsCapital/OutFundCheckDialog'
 
import queryFundUnitContributionOrgList from '@/controller/queryFundUnitContributionOrgList'
 
const normalButtons = [
  { text: '修改', prop: 'editButton' },
  { text: '删除', prop: 'deleteButton' }
]
 
export default {
  name: 'protocolImg',
  components: {
    CommForm,
    CommTable,
    OutFundCheckDialog,
    Dialog,
    SectionTitle
  },
  props: {
    conf: {
      type: Object,
      default: () => ({})
    },
    initValue: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      loading: false,
      isShowDel: false,
      tableHeader: [],
      model: null,
      list: [],
      tempRecord: {},
      dialogList: false,
      dialogTitle: ''
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      const { isEdit, initValue } = this
      const { query } = this.$route
      this.query = query
      const model = queryFundUnitContributionOrgList()
      const tabList = model.getTableList()
      this.formList = model.getFormList(initValue)
      this.formRules = model.getFormRules()
 
      this.tableHeader = isEdit
        ? tabList
        : tabList.filter(({ type }) => type !== 'buttons')
      this.model = model
 
      this.getList()
    },
 
    async getList() {
      this.loading = true
      const { model, query } = this
      const { serialNo = '' } = query
      const res = await model.request({
        serialNo
      })
      this.loading = false
      const { list = [] } = res
      this.list = list.map(item => ({
        ...item,
        action: {
          buttons: normalButtons
        }
      }))
      this.listBackUp = [...this.list]
    },
 
    addRecord() {
      this.dialogList = true
      this.dialogTitle = '0'
      this.tempRecord = {}
    },
    doAction(item, record, index) {
      const { prop } = item
      this.currentIndex = index
      this.buttonProp = prop
      this.tempRecord = record
 
      // 删除
      if (prop === 'deleteButton') {
        this.isShowDel = true
      }
      // 修改
      if (prop === 'editButton') {
        // console.log(record)
        this.dialogTitle = '1'
        this.dialogList = true
      }
    },
 
    updateTableValue() {
      const { list } = this
      const { name } = inputItem
      const listItem = list[recordIndex]
      const key = Object.keys(listItem).find(k => k === name)
      this.$set(list, recordIndex, {
        ...listItem,
        [key]: { ...listItem[key], value: val }
      })
      this.listBackUp = [...this.list]
    },
 
    toShowSucc(data, options) {
      this.dialogList = false
      const { list, currentIndex = 0, dialogTitle } = this
      const { orgTypeOptions, distributionOptions } = options
      const { orgType, incomeDistributionMode } = data
      const orgTypeDesc = orgTypeOptions.find(({ value }) => value === orgType)
        .label
 
      const incomeDistributionModeDesc = distributionOptions.find(
        ({ value }) => value === incomeDistributionMode
      ).label
      if (dialogTitle === '0') {
        this.list.push({
          ...data,
          orgTypeDesc,
          incomeDistributionModeDesc,
          action: {
            buttons: normalButtons
          }
        })
      } else {
        this.$set(list, currentIndex, {
          ...data,
          orgTypeDesc,
          incomeDistributionModeDesc,
          action: {
            buttons: normalButtons
          }
        })
      }
      this.listBackUp = [...this.list]
      console.log(this.list, currentIndex)
    },
 
    clickDel(index) {
      if (index === 0) {
        this.isShowDel = false
      } else {
        this.toDel()
      }
    },
    // 删除操作
    toDel() {
      const { currentIndex, list } = this
      const delIndex = list.findIndex((item, index) => index === currentIndex)
      this.list.splice(delIndex, 1)
      this.listBackUp = [...this.list]
      this.isShowDel = false
      console.log('删除成功')
    },
 
    submit() {
      // console.log(this.list)
      this.setFundUnitContributionOrgSubmitReqs(this.list)
    },
 
    ...mapMutations(['setFundUnitContributionOrgSubmitReqs'])
  },
  computed: {
    isEdit() {
      const { conf } = this
      return conf.edit === 'Y'
    },
    formValues() {
      const { model, formList } = this
      return model.getFormValues(formList)
    }
  }
}
</script>
 
<style scoped>
</style>