|
@@ -5,12 +5,15 @@
|
|
|
<span v-if="display == 'list'">
|
|
|
<el-col :span="24" class="top">
|
|
|
<el-button type="primary" size="mini" @click="add">添加信息</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="importBtn">导入数据</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="importOut">导出数据</el-button>
|
|
|
+ <el-button type="info" size="mini"> <el-link :underline="false" style="color:#fff" href="/数据模板.xlsx">数据模板下载</el-link></el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="list">
|
|
|
<data-table :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete" @query="search"></data-table>
|
|
|
</el-col>
|
|
|
</span>
|
|
|
- <span v-else>
|
|
|
+ <span v-else-if="display == 'detail'">
|
|
|
<el-col :span="24" class="top">
|
|
|
<el-button type="primary" size="mini" @click="back">返回</el-button>
|
|
|
</el-col>
|
|
@@ -24,6 +27,32 @@
|
|
|
</data-form>
|
|
|
</el-col>
|
|
|
</span>
|
|
|
+ <span v-else>
|
|
|
+ <el-col :span="24" class="top">
|
|
|
+ <el-button type="primary" size="mini" @click="back">返回</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="import">
|
|
|
+ <uploadFile :limit="1" :data="fileForm.uri" listType="" type="uri" :url="'/files/uri/upload'" @upload="importSuccess"></uploadFile>
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" size="mini" @click="importSubmit">确定导入</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="error" v-if="errorList.length > 0">
|
|
|
+ <el-col :span="24" class="title">
|
|
|
+ 错误列表
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="errorList">
|
|
|
+ <p>
|
|
|
+ <span>序号</span>
|
|
|
+ <span>错误信息</span>
|
|
|
+ </p>
|
|
|
+ <p v-for="(item, index) in errorList" :key="index">
|
|
|
+ <span>{{ index + 1 }}</span>
|
|
|
+ <span>{{ item }}</span>
|
|
|
+ </p>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </span>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
@@ -33,8 +62,10 @@
|
|
|
import dataTable from '@/components/data-table.vue';
|
|
|
import dataForm from '@/components/form.vue';
|
|
|
import upload from '@/components/uploadone.vue';
|
|
|
+import uploadFile from '@/components/upload/uploadFile.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: patent } = createNamespacedHelpers('patent');
|
|
|
+const { mapActions: patentImport } = createNamespacedHelpers('patentImport');
|
|
|
export default {
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
@@ -45,6 +76,7 @@ export default {
|
|
|
dataTable,
|
|
|
dataForm,
|
|
|
upload,
|
|
|
+ uploadFile,
|
|
|
},
|
|
|
data: function() {
|
|
|
return {
|
|
@@ -106,6 +138,9 @@ export default {
|
|
|
agent: [{ required: false, message: '代理机构', trigger: 'blur' }],
|
|
|
abstract: [{ required: false, message: '摘要', trigger: 'blur' }],
|
|
|
},
|
|
|
+ fileForm: {},
|
|
|
+ // 错误信息
|
|
|
+ errorList: [],
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
@@ -113,6 +148,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
...patent(['query', 'fetch', 'update', 'create', 'delete']),
|
|
|
+ ...patentImport({ importCreate: 'create' }),
|
|
|
// 查询列表
|
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
let res = await this.query({ skip, limit, ...info });
|
|
@@ -173,6 +209,9 @@ export default {
|
|
|
},
|
|
|
// 返回
|
|
|
back() {
|
|
|
+ this.form = {};
|
|
|
+ this.fileForm = {};
|
|
|
+ this.errorList = [];
|
|
|
this.display = 'list';
|
|
|
this.search();
|
|
|
},
|
|
@@ -180,6 +219,34 @@ export default {
|
|
|
uploadSuccess({ type, data }) {
|
|
|
this.$set(this.form, `${type}`, data.uri);
|
|
|
},
|
|
|
+ // 导入数据
|
|
|
+ importBtn() {
|
|
|
+ this.display = 'import';
|
|
|
+ },
|
|
|
+ importSuccess({ type, data }) {
|
|
|
+ if (data.uri) this.$set(this.fileForm, `uri`, data.uri);
|
|
|
+ },
|
|
|
+ async importSubmit() {
|
|
|
+ let data = this.fileForm;
|
|
|
+ let res = await this.importCreate(data);
|
|
|
+ if (res.data) {
|
|
|
+ this.$set(this, 'errorList', res.data);
|
|
|
+ this.$message({
|
|
|
+ message: '信息错误,请重新编辑数据!',
|
|
|
+ type: 'error',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: '修改信息成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.back();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 导出书卷
|
|
|
+ importOut() {
|
|
|
+ alert('导出数据');
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
@@ -195,5 +262,40 @@ export default {
|
|
|
text-align: right;
|
|
|
margin: 0 0 10px 0;
|
|
|
}
|
|
|
+ .import {
|
|
|
+ .btn {
|
|
|
+ padding: 20px 0;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ .error {
|
|
|
+ .title {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: bold;
|
|
|
+ padding: 0 0 10px 0;
|
|
|
+ color: #ff0000;
|
|
|
+ }
|
|
|
+ .errorList {
|
|
|
+ p {
|
|
|
+ float: left;
|
|
|
+ width: 100%;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ height: 30px;
|
|
|
+ line-height: 30px;
|
|
|
+ font-size: 16px;
|
|
|
+ span:nth-child(1) {
|
|
|
+ float: left;
|
|
|
+ width: 9%;
|
|
|
+ text-align: center;
|
|
|
+ border-right: 2px solid #ccc;
|
|
|
+ }
|
|
|
+ span:nth-child(2) {
|
|
|
+ float: left;
|
|
|
+ width: 90%;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|