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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<template>
  <div class="other-share-holder">
    <el-row class="add-button" v-if="addorupdate === '01'">
      <el-col :span="24">
        <el-button
          type="primary"
          size="small"
          icon="el-icon-circle-plus-outline"
          @click="handleAddCus"
          class="add_btn"
        >新增</el-button>
      </el-col>
    </el-row>
 
    <ProTable
      :pageInfo="pageInfo"
      @doAction="doAction"
      @handleCurrentChange="handleCurrentChange"
      @handleSizeChange="handleSizeChange"
      :isAutoIndex="true"
      :list="records"
      :header="tableHeader"
      :loading="loading"
    />
 
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      :show-close="false"
      custom-class="stock_dialog"
      width="890px"
      center
    >
      <CreateForms
        ref="financeForms"
        v-if="dialogVisible"
        :isReset="true"
        :isView="isView"
        :isShowBorder="isShowBorder"
        :screenWidth="1000"
        :formItems="formItems"
        :defValues="defValues"
        :formRules="formRules"
        @beforeFormAvatarUpload="beforeAvatarUpload"
        @handleFormUpload="handleUpload"
        @handleFormDelete="handleDelete"
      />
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleDialogCancel">取消</el-button>
        <el-button type="primary" v-if="!isView" @click="saveBoardInfo">
          {{
          addOrModify === "0" ? "新增" : "修改"
          }}
        </el-button>
      </span>
    </el-dialog>
 
    <Dialog
      v-model="isDelete"
      title="财务信息删除确认"
      :buttons="[{text: '取消'},{text: '确定', type: 'primary'}]"
      @handleClick="clickDelete"
      :contentText="`请确认是否需要删除${tempRecord.financialTypeCn}财务信息?`"
    ></Dialog>
  </div>
</template>
 
<script>
// 财务信息
import ProTable from "@/views/components/ProTable";
import CreateForms from "@/views/components/CreateForms";
import Dialog from "../components/Dialog";
import OperateSuccessTip from "../components/OperateSuccessTip";
 
import {
  qryFinancialDataList,
  delFinancialData,
  financialDataUpdate,
  getDictionaryList
} from "@/http/api.js";
import { enterpriseCusFinanceInfo } from "../config/column.config";
import { financeInfoDefault } from "../config/defValues.config";
import { financeInfo } from "../config/formItem.config";
import { financeInfoRules } from "../config/rules.config";
export default {
  components: {
    ProTable,
    Dialog,
    OperateSuccessTip,
    CreateForms
  },
  props: {
    tableHeader: {
      type: [Object, Array],
      default: () => {
        return [];
      }
    },
    addorupdate: {
      type: [String],
      default: ""
    }
  },
  created() {
    this.init();
  },
  data() {
    return {
      operateBtns: [{ label: "删除", type: "DELETE", value: true }],
      columnConfig: [...enterpriseCusFinanceInfo],
      loading: false,
      isShowBorder: true,
      dialogTitle: "",
      isView: false,
      dialogVisible: false,
      formItems: [...financeInfo],
      formRules: { ...financeInfoRules },
      defValues: { ...financeInfoDefault },
      addOrModify: "", // 0-新增 1-修改
      pageInfo: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      records: [],
      tempRecord: {},
      isDelete: false,
      passValidate: false, // 控制是否通过检验
      objectNo: "" // 存放customerId
    };
  },
  methods: {
    async init() {
      const { pageInfo, $route } = this;
      const { query } = $route;
 
      const { customerId, operation } = query;
      this.objectNo = customerId;
      const params = {
        objectNo: customerId,
        ...pageInfo
      };
      const { result } = await qryFinancialDataList(params);
      // 给每行数据添加操作按钮
      this.records = result.records.map(item => {
        const newItem = { ...item };
        if (operation === "02") {
        } else {
          newItem.operationOption = [
            { key: "delete", label: "删除", value: true },
            { key: "edit", label: "修改", value: true }
          ];
        }
        return newItem;
      });
      this.$set(this.pageInfo, "total", result.total);
    },
    // 新增
    handleAddCus() {
      this.isView = false;
      this.isShowBorder = true;
      this.setSelectOptions();
      this.dialogTitle = "新增财务信息";
      this.dialogVisible = true;
      this.addOrModify = "0";
      const { defValues } = this;
      for (let key in defValues) {
        defValues[key] = "";
      }
    },
    setSelectOptions() {
      const { formItems } = this;
      formItems.forEach(({ name }) => {
        if (name === "financialType") {
          this.getDictionaryList(name);
        }
      });
    },
    async getDictionaryList(name) {
      const codeNo = name.substring(0, 1).toUpperCase() + name.substring(1);
      const { result } = await getDictionaryList({ codeNo });
      const list = result.map(item => {
        return {
          label: item.itemname,
          value: item.itemno
        };
      });
      this.updateValue(name, { options: list });
    },
    updateValue(index, info) {
      const { formItems } = this;
      const nameIndex = formItems.findIndex(({ name }) => name === index);
      if (nameIndex > -1) {
        const preInfo = formItems[nameIndex];
        this.$set(formItems, nameIndex, { ...preInfo, ...info });
      }
    },
    // 取消
    handleDialogCancel() {
      this.serialno = ''
      this.dialogVisible = false;
    },
 
    // 保存/修改
    async saveBoardInfo() {
      const { objectNo, serialno } = this;
      await this.vailateForm();
      const { passValidate } = this;
      if (!passValidate) {
        return false;
      }
      const formRef = this.$refs.financeForms;
      const { model } = formRef.$refs["createForm"];
      let temp = serialno
        ? { ...model, objectNo, serialno }
        : { ...model, objectNo };
      await financialDataUpdate(temp);
      this.dialogVisible = false;
      this.$message.success(`${serialno ? "修改成功" : "新增成功"}`);
      this.serialno = "";
      this.init();
    },
    vailateForm() {
      const formRef = this.$refs.financeForms;
      formRef.$refs["createForm"].validate(async valid => {
        if (valid) {
          this.passValidate = true;
          return true;
        } else {
          this.passValidate = false;
          this.$message.error("请完善必填项!");
          return false;
        }
      });
    },
    beforeAvatarUpload() {},
    handleUpload() {},
    handleDelete() {},
    // 修改翻页条数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.getBoardList();
    },
    // 修改翻页数
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val;
      this.getBoardList();
    },
    // 表单事件回调
    doAction(name, item, { key }) {
      this.tempRecord = item;
      if (key === "delete") {
        this.isDelete = true;
      }
      if (key === "edit") {
        this.toEdit();
        this.dialogVisible = true;
        this.dialogTitle = "修改财务信息";
      }
    },
    toEdit() {
      const { tempRecord, defValues } = this;
      this.setSelectOptions();
      // defValues.financialType = '01'
      for (let key in defValues) {
        for (let tempKey in tempRecord) {
          if (key === tempKey) {
            defValues[key] = tempRecord[tempKey];
          }
        }
      }
      this.serialno = tempRecord.serialno;
    },
    // 删除按钮回调事件
    clickDelete(index) {
      if (index === 0) {
        this.isDelete = false;
      } else {
        this.toDelete();
      }
    },
 
    async toDelete() {
      const { tempRecord } = this;
      const { serialno } = tempRecord;
      try {
        await delFinancialData({ serialno });
        this.$message.success("删除成功");
        this.isDelete = false;
        this.init();
      } catch (error) {
        this.isDelete = false;
      }
    }
  }
};
</script>
 
<style lang="less" scoped>
.other-share-holder {
  & .add-button {
    margin-bottom: 20px;
  }
  & .stock_dialog {
    & .el-dialog__footer {
      & .dialog-footer {
        & .el-button--default {
          width: 120px;
          height: 30px;
          line-height: 7px;
          border-radius: 4px;
          border: 1px solid rgba(204, 204, 204, 1);
        }
        & .el-button--primary {
          width: 120px;
          height: 30px;
          line-height: 7px;
          background: #0081f0;
          border-color: #0081f0;
          border-radius: 4px;
          margin-left: 40px;
        }
      }
    }
  }
}
</style>