From 09da100729793848bc01b51f7b05ca3f1e7ec64f Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 20 六月 2024 14:05:35 +0800
Subject: [PATCH] 提交一把
---
company/src/components/business/OperaInsuranceWindow.vue | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 100 insertions(+), 10 deletions(-)
diff --git a/company/src/components/business/OperaInsuranceWindow.vue b/company/src/components/business/OperaInsuranceWindow.vue
index 96059c6..914aec3 100644
--- a/company/src/components/business/OperaInsuranceWindow.vue
+++ b/company/src/components/business/OperaInsuranceWindow.vue
@@ -1,17 +1,21 @@
<template>
<GlobalWindow
- :title="title"
- :visible.sync="visible"
- :confirm-working="isWorking"
- @confirm="confirm"
+ :title="title"
+ :visible.sync="visible"
+ :confirm-working="isWorking"
+ @confirm="confirm"
>
<el-form :model="form" ref="form" :rules="rules">
<el-form-item label="淇濋櫓鍏徃" prop="name">
<el-input v-model="form.name" placeholder="骞冲畨淇濋櫓" v-trim/>
</el-form-item>
- <el-button type="primary" style="margin-bottom: 10px;">娣诲姞</el-button>
+ <div style="width: 100%; display: flex; align-items: center;margin-bottom: 10px;">
+ <el-button type="primary" @click="add">娣诲姞</el-button>
+ <el-button type="primary" @click="impor">瀵煎叆宸ョ</el-button>
+ <el-button type="text" @click="exprot">瀵煎叆妯$増xls</el-button>
+ </div>
<el-table
- :data="tableData"
+ :data="form.worktypeList"
border
style="width: 100%; margin-bottom: 20px;">
<el-table-column
@@ -34,17 +38,21 @@
align="center"
width="100">
<template slot-scope="scope">
- <el-button type="text" size="small" style="color: red;">鍒犻櫎</el-button>
+ <el-button type="text" size="small" style="color: red;" @click="dele(scope.$index)">鍒犻櫎</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
+ <!-- 涓婁紶宸ョ -->
+ <input type="file" @change="getFile" style="opacity: 0;" ref="upload" accept=".xlsx" />
</GlobalWindow>
</template>
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
+ import { importExcel, all } from '@/api/business/worktype'
+
export default {
name: 'OperaInsuranceWindow',
extends: BaseOpera,
@@ -54,12 +62,14 @@
// 琛ㄥ崟鏁版嵁
form: {
id: null,
- name: ''
+ name: '',
+ worktypeList: [
+ { name: '' }
+ ]
},
// 楠岃瘉瑙勫垯
rules: {
- },
- tableData: []
+ }
}
},
created () {
@@ -67,6 +77,86 @@
api: '/business/insurance',
'field.id': 'id'
})
+ },
+ methods: {
+ open (title, target) {
+ this.form.worktypeList = [{ name: '' }]
+ this.title = title
+ this.visible = true
+ // 鏂板缓
+ if (target == null) {
+ this.$nextTick(() => {
+ this.$refs.form.resetFields()
+ this.form[this.configData['field.id']] = null
+ })
+ return
+ }
+ // 缂栬緫
+ this.$nextTick(() => {
+ for (const key in this.form) {
+ this.form[key] = target[key]
+ }
+ all({ insuranceId: this.form.id })
+ .then(res => {
+ let arr = []
+ res.forEach(item => {
+ arr.push({ name: item.name })
+ })
+ this.form.worktypeList = arr
+ })
+ })
+ },
+ // 瀵煎嚭妯℃澘
+ exprot() {
+ window.open(process.env.VUE_APP_TYPEWORK_URL)
+ // let a = document.createElement("a");
+ // a.href = '/public/file/typeWork.xlsx';
+ // a.download = '淇濋櫓鍏徃-宸ョ瀵煎叆妯$増.xlsx';
+ // a.click();
+ },
+ // 瀵煎叆宸ョ妯℃澘
+ getFile(e) {
+ const formdate = new FormData()
+ formdate.append('file', e.target.files[0])
+ importExcel(formdate)
+ .then(res => {
+ res.forEach(item => {
+ if (this.form.worktypeList.length === 0) {
+ this.form.worktypeList.push({ name: item })
+ } else {
+ let next = true
+ this.form.worktypeList.forEach(row => {
+ if (row.name === item) {
+ next = false
+ }
+ })
+ if (next) {
+ this.form.worktypeList.push({ name: item })
+ }
+ }
+ })
+ })
+ .catch(err => {
+ this.$message.error(err.message)
+ })
+ .finally(() => {
+ this.$refs.upload.value = null
+ })
+ },
+ // 涓婁紶鏂囦欢
+ impor() {
+ this.$refs.upload.click()
+ },
+ add() {
+ this.form.worktypeList.push({ name: '' })
+ },
+ dele(index) {
+ if (this.form.worktypeList.length === 1) {
+ this.$message.warning('鑷冲皯淇濈暀涓�椤瑰唴瀹�')
+ return
+ }
+ this.form.worktypeList.splice(index, 1)
+ }
}
}
</script>
--
Gitblit v1.9.3