detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div id="detail">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <cSearch :is_back="true" @toBack="toBack"></cSearch>
  7. </el-col>
  8. <el-col :span="24" class="two">
  9. <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit" @dataChange="dataChange" :disabled="disabled" :isSave="!disabled">
  10. <template #messattribute>
  11. <el-option v-for="(i, index) in product_messattributeList" :key="index" :label="i.label" :value="i.value"></el-option>
  12. </template>
  13. <template #achievesource>
  14. <el-option v-for="(i, index) in product_achievesourceList" :key="index" :label="i.label" :value="i.value"></el-option>
  15. </template>
  16. <template #achievestatus>
  17. <el-option v-for="(i, index) in product_achievestatusList" :key="index" :label="i.label" :value="i.value"></el-option>
  18. </template>
  19. <template #cooperation>
  20. <el-option v-for="(i, index) in product_cooperationList" :key="index" :label="i.label" :value="i.value"></el-option>
  21. </template>
  22. <template #field>
  23. <el-option v-for="(i, index) in product_fieldList" :key="index" :label="i.label" :value="i.value"></el-option>
  24. </template>
  25. <template #demand>
  26. <el-option v-for="(i, index) in product_demandList" :key="index" :label="i.label" :value="i.value"></el-option>
  27. </template>
  28. <template #type>
  29. <el-option v-for="(i, index) in product_typeList" :key="index" :label="i.label" :value="i.value"></el-option>
  30. </template>
  31. <template #status>
  32. <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
  33. </template>
  34. <template #roadshow="{ item }">
  35. <cUpload :model="item.model" :limit="1" url="/files/zkzx/product/upload" :list="form[item.model]" @change="onUpload"></cUpload>
  36. </template>
  37. <template #file="{ item }">
  38. <cUpload
  39. :model="item.model"
  40. :limit="6"
  41. url="/files/zkzx/product/upload"
  42. :list="form[item.model]"
  43. listType="picture-card"
  44. @change="onUpload"
  45. ></cUpload>
  46. </template>
  47. <template #patent>
  48. <el-col :span="24" class="logs">
  49. <el-col :span="24" class="logs_1">
  50. <el-button type="primary" size="small" @click="add()">添加</el-button>
  51. </el-col>
  52. <el-col :span="24">
  53. <el-table :data="form.patent" style="width: 100%" border>
  54. <el-table-column type="index" label="序号" width="100" align="center"> </el-table-column>
  55. <el-table-column label="名称" align="center">
  56. <template #default="scope">
  57. <el-input v-model="scope.row.name" placeholder="请输入名称" clearable />
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="状态" align="center">
  61. <template #default="scope">
  62. <el-select v-model="scope.row.status" placeholder="请选择">
  63. <el-option v-for="item in product_patent_statusList" :key="item.value" :label="item.label" :value="item.value" />
  64. </el-select>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="操作" align="center" width="100">
  68. <template v-slot="scope">
  69. <el-button size="mini" type="danger" @click="del(scope.row)">删除</el-button>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. </el-col>
  74. </el-col>
  75. </template>
  76. </cForm>
  77. </el-col>
  78. </el-col>
  79. </el-row>
  80. </div>
  81. </template>
  82. <script setup lang="ts">
  83. import moment from 'moment';
  84. import type { Ref } from 'vue';
  85. import { ref, reactive, onMounted } from 'vue';
  86. import { useRoute } from 'vue-router';
  87. import { ElMessage } from 'element-plus';
  88. import type { FormRules } from 'element-plus';
  89. import store from '@/stores/counter';
  90. // 接口
  91. import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
  92. import { ProductStore } from '@common/src/stores/allAdmin/product';
  93. import type { IQueryResult } from '@/util/types.util';
  94. const product = ProductStore();
  95. const dictData = DictDataStore();
  96. // 路由
  97. const route = useRoute();
  98. // 加载中
  99. const loading = ref(false);
  100. let user: Ref<any> = ref({});
  101. // 表单
  102. let disabled: Ref<any> = ref(false);
  103. let form: Ref<any> = ref({});
  104. let formFields: Ref<any[]> = ref([
  105. // 公共
  106. { label: '类型', model: 'type', type: 'select' },
  107. { label: '企业名称', model: 'company' },
  108. { label: '联系人', model: 'contact' },
  109. { label: '手机号', model: 'phone' },
  110. { label: '电子邮箱', model: 'email' },
  111. { label: 'qq&微信', model: 'qqwx' },
  112. { label: '状态', model: 'status', type: 'select' }
  113. ]);
  114. const rules = reactive<FormRules>({
  115. type: [{ required: true, message: '请选择类型' }]
  116. });
  117. // 字典表
  118. let statusList: Ref<any> = ref([]); // 状态
  119. let product_messattributeList: Ref<any> = ref([]); // 信息属性
  120. let product_achievesourceList: Ref<any> = ref([]); // 成果来源
  121. let product_achievestatusList: Ref<any> = ref([]); // 成果状态
  122. let product_cooperationList: Ref<any> = ref([]); // 合作方式
  123. let product_fieldList: Ref<any> = ref([]); // 所属领域
  124. let product_demandList: Ref<any> = ref([]); // 需求紧急程度/需求程度
  125. let product_typeList: Ref<any> = ref([]); // 类型
  126. let product_patent_statusList: Ref<any> = ref([]); // 专利信息状态
  127. onMounted(async () => {
  128. loading.value = true;
  129. if (route.query.isdisabled) disabled.value = route.query.isdisabled;
  130. user.value = store.state.user;
  131. await searchOther();
  132. await search();
  133. loading.value = false;
  134. });
  135. const search = async () => {
  136. if (route.query.id) {
  137. let res: IQueryResult = await product.fetch(route.query.id);
  138. if (res.errcode == 0) {
  139. form.value = res.data as {};
  140. if (form.value.type == '0') valueOne(); // 科技需求
  141. else if (form.value.type == '1') valueTwo(); // 技术成果
  142. else if (form.value.type == '2') valueThr(); // 商务服务
  143. }
  144. } else form.value = { status: '0', user_id: user.value._id };
  145. };
  146. const dataChange = (e: { model: string; value: any }) => {
  147. const { model, value } = e;
  148. if (model == 'type') {
  149. if (value == '0') valueOne(); // 科技需求
  150. else if (value == '1') valueTwo(); // 科技成果
  151. else if (value == '2') valueThr(); // 商务服务
  152. }
  153. };
  154. // 任职记录
  155. const add = () => {
  156. form.value.patent.push({ id: moment().valueOf(), name: '', status: '' });
  157. };
  158. // 任职记录删除
  159. const del = (e) => {
  160. form.value.patent = form.value.patent.filter((i) => i.id != e.id);
  161. };
  162. // 科技需求
  163. const valueOne = () => {
  164. formFields.value = [
  165. { label: '类型', model: 'type', type: 'select' },
  166. { label: '企业名称', model: 'company' },
  167. { label: '联系人', model: 'contact' },
  168. { label: '手机号', model: 'phone' },
  169. { label: '电子邮箱', model: 'email' },
  170. { label: 'qq&微信', model: 'qqwx' },
  171. { label: '需求名称', model: 'name' },
  172. { label: '需求紧急程度', model: 'demand', type: 'select' },
  173. { label: '所属领域', model: 'field', type: 'select' },
  174. { label: '投资预算', model: 'budget' },
  175. { label: '合作方式', model: 'cooperation', type: 'select' },
  176. { label: '技术说明', model: 'requirementdesc' },
  177. { label: '预期目标', model: 'expect' },
  178. { label: '需求现状', model: 'present' },
  179. { label: '合作条件及要求', model: 'condition' },
  180. { label: '产品图片(6)', model: 'file', custom: true },
  181. { label: '状态', model: 'status', type: 'select' }
  182. ];
  183. };
  184. // 技术成果
  185. const valueTwo = () => {
  186. formFields.value = [
  187. { label: '类型', model: 'type', type: 'select' },
  188. { label: '企业名称', model: 'company' },
  189. { label: '联系人', model: 'contact' },
  190. { label: '手机号', model: 'phone' },
  191. { label: '电子邮箱', model: 'email' },
  192. { label: 'qq&微信', model: 'qqwx' },
  193. { label: '成果名称', model: 'name' },
  194. { label: '所属领域', model: 'field', type: 'select' },
  195. { label: '合作方式', model: 'cooperation', type: 'select' },
  196. { label: '成果状态', model: 'achievestatus', type: 'select' },
  197. { label: '成果权属', model: 'achieveown' },
  198. { label: '成果来源', model: 'achievesource', type: 'select' },
  199. { label: '意向价格', model: 'intentionprice' },
  200. { label: '专利信息', model: 'patent', custom: true }, //Array
  201. { label: '项目路演', model: 'roadshow', custom: true }, //Array
  202. { label: '成果简介', model: 'achievebrief', type: 'textarea' },
  203. { label: '技术特点', model: 'features' },
  204. { label: '技术团队', model: 'team' },
  205. { label: '商业预期', model: 'expect' },
  206. { label: '合作条件及要求', model: 'condition' },
  207. { label: '产品图片(6)', model: 'file', custom: true },
  208. { label: '状态', model: 'status', type: 'select' }
  209. ];
  210. };
  211. // 商务服务
  212. const valueThr = () => {
  213. formFields.value = [
  214. { label: '类型', model: 'type', type: 'select' },
  215. { label: '企业名称', model: 'company' },
  216. { label: '联系人', model: 'contact' },
  217. { label: '手机号', model: 'phone' },
  218. { label: '电子邮箱', model: 'email' },
  219. { label: 'qq&微信', model: 'qqwx' },
  220. { label: '信息名称', model: 'name' },
  221. { label: '信息属性', model: 'messattribute', type: 'select' },
  222. { label: '需求程度', model: 'demand', type: 'select' },
  223. { label: '信息描述', model: 'informationdesc', type: 'textarea' },
  224. { label: '核心要素', model: 'coreelements' },
  225. { label: '价格信息', model: 'priceinfo' },
  226. { label: '商业预期', model: 'expect' },
  227. { label: '状态', model: 'status', type: 'select' }
  228. ];
  229. };
  230. const onUpload = (e: { model: string; value: Array<[]> }) => {
  231. const { model, value } = e;
  232. form.value[model] = value;
  233. };
  234. // 提交
  235. const onSubmit = async (data) => {
  236. let res: IQueryResult;
  237. if (data._id) res = await product.update(data);
  238. else res = await product.create(data);
  239. if (res.errcode == 0) {
  240. ElMessage({ type: `success`, message: `维护信息成功` });
  241. toBack();
  242. }
  243. };
  244. // 返回上一页
  245. const toBack = () => {
  246. window.history.go(-1);
  247. };
  248. const searchOther = async () => {
  249. let res: IQueryResult;
  250. // 类型
  251. res = await dictData.query({ type: 'product_type' });
  252. if (res.errcode == 0) product_typeList.value = res.data;
  253. // 状态
  254. res = await dictData.query({ type: 'product_status' });
  255. if (res.errcode == 0) statusList.value = res.data;
  256. // 信息属性
  257. res = await dictData.query({ type: 'product_messattribute' });
  258. if (res.errcode == 0) product_messattributeList.value = res.data;
  259. // 成果来源
  260. res = await dictData.query({ type: 'product_achievesource' });
  261. if (res.errcode == 0) product_achievesourceList.value = res.data;
  262. // 成果状态
  263. res = await dictData.query({ type: 'product_achievestatus' });
  264. if (res.errcode == 0) product_achievestatusList.value = res.data;
  265. // 合作方式
  266. res = await dictData.query({ type: 'product_cooperation' });
  267. if (res.errcode == 0) product_cooperationList.value = res.data;
  268. // 所属领域
  269. res = await dictData.query({ type: 'product_field' });
  270. if (res.errcode == 0) product_fieldList.value = res.data;
  271. // 需求紧急程度/需求程度
  272. res = await dictData.query({ type: 'product_demand' });
  273. if (res.errcode == 0) product_demandList.value = res.data;
  274. // 专利信息状态
  275. res = await dictData.query({ type: 'product_patent_status' });
  276. if (res.errcode == 0) product_patent_statusList.value = res.data;
  277. };
  278. </script>
  279. <style scoped lang="scss"></style>