|
@@ -1,164 +1,72 @@
|
|
|
<template>
|
|
|
<div id="detail">
|
|
|
- <data-form :fields="fields" :data="data" @save="toSave" returns="/adminCenter/product" @filterReturn="toSelect">
|
|
|
- <template #options="{ item }">
|
|
|
- <template v-if="item.model === 'type'">
|
|
|
- <el-option v-for="(i, index) in typeList" :key="`type-${index}`" :label="i.label" :value="i.value"></el-option>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- <template #custom="{ item }">
|
|
|
- <template v-if="item.model === 'image'">
|
|
|
- <e-upload url="/files/cysci/product_image/upload" v-model="data[item.model]"></e-upload>
|
|
|
- </template>
|
|
|
- <template v-if="item.model === 'roadshow'">
|
|
|
- <e-upload url="/files/cysci/product_roadshow/upload" v-model="data[item.model]" type="text"></e-upload>
|
|
|
- </template>
|
|
|
- <template v-if="item.model === 'patent'">
|
|
|
- <el-row type="flex" justify="end" style="padding-bottom: 10px">
|
|
|
- <el-col :span="2">
|
|
|
- <el-button type="primary" @click="data[item.model].push({})">添加</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row>
|
|
|
- <el-col :span="8" v-for="(i, index) in data[item.model]" :key="`patent-${index}`">
|
|
|
- <el-form-item label="专利信息">
|
|
|
- <el-input v-model="i.patentinfo" placeholder="请填写专利信息"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="专利状态">
|
|
|
- <el-input v-model="i.patentstatus" placeholder="请填写专利状态"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-row type="flex" justify="space-around">
|
|
|
- <el-col :span="2">
|
|
|
- <el-button type="danger" @click="data[item.model].splice(index, 1)">删除</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </data-form>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <el-col :span="24" class="top">
|
|
|
+ <el-button type="primary" size="mini" @click="back">返回</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="down">
|
|
|
+ <one v-if="type == '0'" :form="form" @back="back" @onSubmit="onSubmit"></one>
|
|
|
+ <two v-else-if="type == '1'" :form="form" @back="back" @onSubmit="onSubmit"></two>
|
|
|
+ <thr v-else-if="type == '2'" :form="form" @back="back" @onSubmit="onSubmit"></thr>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-const _ = require('lodash');
|
|
|
-const { productType } = require('@common/dict/index');
|
|
|
+import one from './parts/one.vue';
|
|
|
+import two from './parts/two.vue';
|
|
|
+import thr from './parts/thr.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: product } = createNamespacedHelpers('product');
|
|
|
export default {
|
|
|
- name: 'productDetail',
|
|
|
+ name: 'detail',
|
|
|
props: {},
|
|
|
- components: {},
|
|
|
+ components: {
|
|
|
+ one,
|
|
|
+ two,
|
|
|
+ thr,
|
|
|
+ },
|
|
|
data: function () {
|
|
|
return {
|
|
|
- typeList: productType,
|
|
|
- data: {
|
|
|
- image: [],
|
|
|
- roadshow: [],
|
|
|
- patent: [],
|
|
|
- },
|
|
|
- fields: [],
|
|
|
- fieldsPublic: [
|
|
|
- { label: '名称', model: 'name' },
|
|
|
- { label: '联系人', model: 'contacts' },
|
|
|
- { label: '联系电话', model: 'phone' },
|
|
|
- { label: 'qq&微信', model: 'qqwx' },
|
|
|
- { label: '邮箱', model: 'email' },
|
|
|
- { label: '类型', model: 'type', type: 'select', filterReturn: true },
|
|
|
- // 共同
|
|
|
- { label: '所属领域', model: 'field' },
|
|
|
- { label: '合作方式', model: 'cooperation' },
|
|
|
- { label: '企业名称', model: 'company' },
|
|
|
- { label: '合作条件及要求', model: 'condition', type: 'textArea', options: { maxRows: 5, minRows: 3 } },
|
|
|
- { label: '图片', model: 'image', custom: true },
|
|
|
- { label: '预期', model: 'expect' },
|
|
|
- { label: '需求程度', model: 'demand' },
|
|
|
- ],
|
|
|
-
|
|
|
- // 科技需求
|
|
|
- fields0: [
|
|
|
- { label: '投资预算', model: 'budget' },
|
|
|
- { label: '需求说明', model: 'requirementdesc', options: { maxRows: 5, minRows: 3 } },
|
|
|
- { label: '需求现状', model: 'present' },
|
|
|
- ],
|
|
|
- // 技术成果
|
|
|
- fields1: [
|
|
|
- { label: '成果状态', model: 'achievestatus' },
|
|
|
- { label: '成果权属', model: 'achieveown' },
|
|
|
- { label: '成果来源', model: 'achievesource' },
|
|
|
- { label: '意向价格', model: 'intentionprice' },
|
|
|
- { label: '专利', model: 'patent', custom: true },
|
|
|
- { label: '项目路演', model: 'roadshow', custom: true },
|
|
|
- { label: '成果简介', model: 'achievebrief', options: { maxRows: 5, minRows: 3 } },
|
|
|
- { label: '技术特点', model: 'features', options: { maxRows: 5, minRows: 3 } },
|
|
|
- { label: '技术团队', model: 'team', options: { maxRows: 5, minRows: 3 } },
|
|
|
- ],
|
|
|
- // 商务需求
|
|
|
- fields2: [
|
|
|
- { label: '信息属性', model: 'messattribute' },
|
|
|
- { label: '信息描述', model: 'informationdesc' },
|
|
|
- { label: '核心要素', model: 'coreelements' },
|
|
|
- { label: '价格信息', model: 'priceinfo' },
|
|
|
- ],
|
|
|
+ form: {},
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
- this.$set(this, 'fields', this.fieldsPublic);
|
|
|
- if (this.id) this.search();
|
|
|
+ async created() {
|
|
|
+ await this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
...product(['fetch', 'create', 'update']),
|
|
|
- toSelect({ data, model }) {
|
|
|
- if (model === 'type') {
|
|
|
- const fields = _.get(this, `fields${data}`);
|
|
|
- if (fields) {
|
|
|
- const dup = _.cloneDeep(this.fieldsPublic);
|
|
|
- const last = dup.concat(fields);
|
|
|
- this.$set(this, 'fields', last);
|
|
|
+ async search() {
|
|
|
+ if (this.id) {
|
|
|
+ let res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- async search() {
|
|
|
- const res = await this.fetch(this.id);
|
|
|
+ async onSubmit({ data }) {
|
|
|
+ let res = await this.update(data);
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `data`, res.data);
|
|
|
- const { type } = res.data;
|
|
|
- if (type) this.toSelect({ data: type, model: 'type' });
|
|
|
- }
|
|
|
- },
|
|
|
- async toSave({ data }) {
|
|
|
- let dup = _.cloneDeep(data);
|
|
|
- // 需要根据type,过滤出对应的数据
|
|
|
- dup = this.filterData(dup);
|
|
|
- let res;
|
|
|
- if (_.get(dup, 'id')) {
|
|
|
- res = await this.update(dup);
|
|
|
- } else {
|
|
|
- res = await this.create(dup);
|
|
|
- }
|
|
|
- if (this.$checkRes(res, '保存成功', '保存失败')) {
|
|
|
- if (!this.$dev_mode) this.$router.push('/adminCenter/product');
|
|
|
+ this.$message({
|
|
|
+ message: '信息审核成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.back();
|
|
|
}
|
|
|
},
|
|
|
- filterData(data) {
|
|
|
- const { type, id } = data;
|
|
|
- const publics = _.cloneDeep(this.fieldsPublic);
|
|
|
- const fields = _.get(this, `fields${type}`, []);
|
|
|
- const keys = publics.map((i) => i.model).concat(fields.map((i) => i.model));
|
|
|
- const obj = {};
|
|
|
- for (const key of keys) {
|
|
|
- if (data[key]) obj[key] = data[key];
|
|
|
- }
|
|
|
- if (id) obj.id = id;
|
|
|
- return obj;
|
|
|
+ back() {
|
|
|
+ this.$router.push({ path: '/adminCenter/product', query: { type: this.type } });
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapState(['user', 'menuParams']),
|
|
|
- pageTitle() {
|
|
|
- return `${this.$route.meta.title}`;
|
|
|
+ ...mapState(['user']),
|
|
|
+ type() {
|
|
|
+ return this.$route.query.type;
|
|
|
},
|
|
|
id() {
|
|
|
return this.$route.query.id;
|
|
@@ -167,7 +75,29 @@ export default {
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ test: {
|
|
|
+ deep: true,
|
|
|
+ immediate: true,
|
|
|
+ handler(val) {},
|
|
|
+ },
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
+<style lang="less" scoped>
|
|
|
+.main {
|
|
|
+ border-radius: 10px;
|
|
|
+ box-shadow: 0 0 5px #cccccc;
|
|
|
+ padding: 20px;
|
|
|
+ .one {
|
|
|
+ .top {
|
|
|
+ text-align: right;
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.main:hover {
|
|
|
+ box-shadow: 0 0 5px #409eff;
|
|
|
+}
|
|
|
+</style>
|