index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <div class="workspace height_100">
  3. <!-- <div class="query-top" v-if="[2].indexOf(isOperate) == -1">
  4. <el-collapse>
  5. <el-collapse-item title="图表预览" name="1">
  6. <div class="chart-box">
  7. <total-chart ref="totalChart" />
  8. </div>
  9. </el-collapse-item>
  10. </el-collapse>
  11. </div> -->
  12. <div class="height_100">
  13. <el-container v-if="showView">
  14. <el-header>
  15. <div id="step1">
  16. <mySearch style="width:500px" :SearchFields="searchFiled" @search="search" :searchValue="searchOption"
  17. :disabled="!$permission('/workspace/project/check')"></mySearch>
  18. </div>
  19. <div style="display:flex;margin-right:10px">
  20. <div id="step2" v-if="[2].indexOf(isOperate) == -1">
  21. <span>分组查询:</span>
  22. <el-select v-model="group" :disabled="!$permission('/workspace/project/check')" clearable size="small"
  23. @change="onChange" style="width:200px">
  24. <el-option v-for="item in groupingOption" :key="item.value" :label="item.name" :value="item.value">
  25. </el-option>
  26. </el-select>
  27. </div>
  28. <el-button-group class="margin-left_10" id="step3" v-if="[2].indexOf(isOperate) == -1">
  29. <el-button :type="queryShowType === '2' ? 'primary' : ''" @click="onChange2('2')"
  30. size="small">可视化</el-button>
  31. <el-button :type="queryShowType === '0' ? 'primary' : ''" @click="onChange2('0')"
  32. size="small">列表</el-button>
  33. <el-button :type="queryShowType === '1' ? 'primary' : ''" @click="onChange2('1')"
  34. size="small">卡片</el-button>
  35. </el-button-group>
  36. <el-dropdown id="step4" trigger="click" split-button type="primary" size="small">
  37. <span @click="handleAdd" v-disabled="false">新增专利数据库</span>
  38. <el-dropdown-menu slot="dropdown" class="text-align_center">
  39. <el-dropdown-item @click.native="handleExport" v-if="[2].indexOf(isOperate) == -1">导出列表</el-dropdown-item>
  40. <el-dropdown-item @click.native="handleImport"
  41. :disabled="!$permission('/workspace/project/import')" v-if="[2].indexOf(isOperate) == -1">导入数据包</el-dropdown-item>
  42. <el-dropdown-item @click.native="handleField">显示栏位管理</el-dropdown-item>
  43. </el-dropdown-menu>
  44. </el-dropdown>
  45. </div>
  46. </el-header>
  47. <el-main class="workspace-main height_100">
  48. <div v-loading="loading" class="height_100">
  49. <component v-if="showView" :is="viewType" v-bind="$attrs" v-on="$listeners" :isOperate="isOperate"
  50. :tableData="dataList" :groupBy="group" :groupingOption="groupingOption" :searchOption="searchOption" :scenario="commonData" :matter="matter"
  51. :queryParams="queryParams" :column="fieldList" @option="handleOption" @on-sort="handleSort" :handleMessage="handleMessage"></component>
  52. </div>
  53. </el-main>
  54. <el-footer class="pagination" v-if="[2].indexOf(isOperate) == -1 && this.queryShowType != '2'">
  55. <el-pagination backgroundx layout="total, prev, pager, next, jumper" :current-page.sync="queryParams.current"
  56. :page-size.sync="queryParams.size" @current-change="handleCurrentChange" :total="total">
  57. </el-pagination>
  58. </el-footer>
  59. </el-container>
  60. </div>
  61. <project-form-drawer @submit="getMessage" :common-data="commonData" ref="projectFormDrawer" />
  62. <field ref="field" type="patentProject" @getFieldList="getFieldList"></field>
  63. </div>
  64. </template>
  65. <script>
  66. import { mapGetters } from 'vuex'
  67. import TotalChart from "./components/TotalChart";
  68. import Table from "./components/view/table.vue";
  69. import Card from "./components/view/card.vue";
  70. import mergeTable from "./components/view/MergeTable.vue";
  71. import ProjectFormDrawer from './components/drawer/form.vue'
  72. import field from '@/views/components/dialog/fields.vue';
  73. export default {
  74. components: {
  75. TotalChart,
  76. Table,
  77. Card,
  78. ProjectFormDrawer,
  79. field,
  80. mergeTable,
  81. },
  82. props: {
  83. isOperate: '',
  84. matterId:{},
  85. scenarioId:{},
  86. eventName:'',
  87. eventId:''
  88. },
  89. data() {
  90. return {
  91. //检索字段
  92. searchFiled: [],
  93. //检索条件
  94. searchOption: {
  95. scenarioNames:this.scenarioId,
  96. matterNames:this.matterId,
  97. name:localStorage.searchContent,
  98. eventNames:this.eventName
  99. },
  100. //专利数据库数据总数
  101. total: 0,
  102. //分页信息
  103. queryParams: {
  104. size: 10,
  105. current: 1,
  106. },
  107. //排序
  108. sort: [
  109. {
  110. "orderBy": "createTime",
  111. "orderType": 1
  112. }
  113. ],
  114. //分组集合
  115. groupingOption: [],
  116. //分组
  117. group: '',
  118. //展示的视图
  119. queryShowType: '0',
  120. //显示的视图组件
  121. viewType: 'Table',
  122. //加载
  123. loading: false,
  124. //专利数据库数据集合//分组及不分组公用此变量
  125. dataList: [],
  126. //栏位集合
  127. fieldList: [],
  128. //接受子组件消息
  129. handleMessage: '',
  130. //显示视图
  131. showView: false,
  132. };
  133. },
  134. watch: {},
  135. computed: {
  136. ...mapGetters(['userinfo']),
  137. commonData() {
  138. var a = this.$store.state.dictMessage.scenario.map(item => {
  139. return {
  140. label: item.name,
  141. value: item.id
  142. }
  143. })
  144. var obj = this.searchFiled.find(item => { return item.label == '应用场景' })
  145. if (obj) {
  146. obj.options = a
  147. }
  148. return this.$store.state.dictMessage.scenario || []
  149. },
  150. matter() {
  151. var a = this.$store.state.dictMessage.matter.map(item => {
  152. return {
  153. label: item.name,
  154. value: item.id
  155. }
  156. })
  157. var obj = this.searchFiled.find(item => { return item.label == '调查类型' })
  158. if (obj) {
  159. obj.options = a
  160. }
  161. return this.$store.state.dictMessage.matter || []
  162. }
  163. },
  164. created() { },
  165. async mounted() {
  166. this.fieldList = await this.$commonJS.getCustomField('patentProject')
  167. //获取检索字段和分组字段
  168. await this.getColumn()
  169. //获取专利数据库列表
  170. this.getList()
  171. this.showViews()
  172. },
  173. methods: {
  174. //显示视图?
  175. showViews() {
  176. this.showView = false
  177. this.$nextTick(() => {
  178. this.showView = true
  179. })
  180. },
  181. //获取自定义栏位
  182. getFieldList(data) {
  183. this.fieldList = data
  184. },
  185. //获取检索字段和分组字段
  186. async getColumn() {
  187. let params = ['patentProject']
  188. await this.$api.getParamsCommon(params).then(async res => {
  189. if (res.code == 200) {
  190. // 分组字段
  191. let conditionDTOList = JSON.parse(JSON.stringify(res.data[0].conditionDTOList))
  192. this.groupingOption = this.$commonJS.getField(conditionDTOList, (u) => u.ifGroup == true, {
  193. name: 'name',
  194. value: 'value',
  195. })
  196. // 搜索字段
  197. this.searchFiled = this.$commonJS.getField(conditionDTOList, (u) => u.ifSearch == true, {
  198. label: 'name',
  199. value: 'value',
  200. type: 'type',
  201. })
  202. //为应用场景添加选项
  203. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  204. if(obj){
  205. obj.options = this.commonData.map(item=>{
  206. return {
  207. label:item.name,
  208. value:item.id
  209. }
  210. })
  211. }
  212. var obj = this.searchFiled.find(item=>{return item.label == '调查类型'})
  213. if(obj){
  214. obj.options = this.matter.map(item=>{
  215. return {
  216. label:item.name,
  217. value:item.id
  218. }
  219. })
  220. }
  221. }
  222. })
  223. this.showViews()
  224. },
  225. //检索
  226. search(val) {
  227. let params = {}
  228. val.forEach(item => {
  229. if (item.type == 3) {
  230. params[item.value] = item.searchValue.map(itemValue => {
  231. return itemValue.value
  232. })
  233. } else {
  234. params[item.value] = item.searchValue.label
  235. }
  236. })
  237. this.searchOption = this.$commonJS.ArrayToArray(val)
  238. // 调用查询接口
  239. this.queryParams.current = 1
  240. this.isGrouping()
  241. },
  242. //获取专利数据库列表/卡片数据
  243. getList() {
  244. this.queryParams.size = this.queryShowType === '0' ? 10 : 12
  245. var params = this.queryParams
  246. params = {
  247. ...this.queryParams,//分页信息
  248. searchQuery: this.$commonJS.objectToString(this.searchOption),//检索条件
  249. orderDTOList: this.sort,//排序
  250. }
  251. this.loading = true
  252. this.$api.queryPatentProject(params).then(response => {
  253. this.dataList = response.data.data
  254. this.total = response.data.total
  255. this.loading = false
  256. }).catch(error => {
  257. this.dataList = []
  258. this.total = 0
  259. this.loading = false
  260. })
  261. },
  262. // 获取分组数据
  263. getGrouping() {
  264. let params = {
  265. ...this.queryParams,//分页信息
  266. searchQuery: this.$commonJS.objectToString(this.searchOption),//检索条件
  267. orderDTOList: [
  268. {
  269. orderBy:this.group,
  270. orderType:this.sort[0].orderType
  271. }
  272. ],//排序
  273. groupBy: this.group,//分组的值
  274. }
  275. this.loading = true
  276. this.$api.groupPatentProject(params).then(response => {
  277. this.dataList = response.data.data.values
  278. this.total = response.data.total
  279. this.loading = false
  280. }).catch(error => {
  281. this.dataList = []
  282. this.total = 0
  283. this.loading = false
  284. })
  285. },
  286. //排序
  287. handleSort({ column, prop, order, str }) {
  288. var params = {
  289. sort:this.sort,
  290. column,
  291. prop,
  292. order,
  293. }
  294. this.sort = this.$commonJS.getSortData(params)//如需要多个字段排序,则不需要清空
  295. this.queryParams.current = 1
  296. //1表示展开行2表示基础表格
  297. if (str == '1') {
  298. this.getGrouping()
  299. } else {//table排序
  300. this.getList()
  301. }
  302. },
  303. //分页
  304. handleCurrentChange(val) {
  305. this.queryParams.current = val;
  306. this.isGrouping();
  307. },
  308. //切换到分组
  309. onChange(val) {
  310. if (val != '') {
  311. this.viewType = 'mergeTable'
  312. } else {
  313. this.viewType = 'Table'
  314. }
  315. this.group = val
  316. this.queryParams.current = 1
  317. this.queryParams.size = 10
  318. this.isGrouping()//区分是否分组,调用不同请求数据
  319. },
  320. // 区分是否为分组
  321. isGrouping() {
  322. if (this.group != '') {//分组
  323. this.getGrouping()
  324. } else {//不分组
  325. this.getList()
  326. }
  327. },
  328. //切换table、卡片视图
  329. onChange2(type) {
  330. var viewTypes = {
  331. '0':'Table',
  332. '1':'Card',
  333. '2':'TotalChart'
  334. }
  335. this.group = ''
  336. this.queryShowType = type
  337. this.viewType = viewTypes[type]
  338. if(type == 2){
  339. return false
  340. }
  341. this.queryParams.current = 1
  342. this.getList()
  343. // this.onChange()
  344. },
  345. //新增专利数据库
  346. handleAdd() {
  347. this.$refs.projectFormDrawer.open({
  348. ifUpdate: false,
  349. updateTime: 'day',
  350. crons: '',
  351. status: '0',
  352. sort: 1,
  353. matterIds:this.matterId || [],
  354. scenarioIds:this.scenarioId || [],
  355. eventName:this.eventName,
  356. eventId:this.eventId
  357. }, '新增专利数据库')
  358. },
  359. //确认提交专利数据库信息
  360. getMessage(val) {
  361. this.handleMessage = val
  362. this.queryParams.current = 1
  363. this.isGrouping()
  364. this.clearMessage()
  365. },
  366. clearMessage() {
  367. this.$emit('submit',true)
  368. this.$nextTick(() => {
  369. this.handleMessage = ''
  370. })
  371. },
  372. //导出列表
  373. handleExport() {
  374. this.btnLoading = true
  375. this.$api.exportProjectList().then(response => {
  376. downLoad(response, getFileName('xlsx'))
  377. this.btnLoading = false
  378. }).catch(error => {
  379. this.btnLoading = false
  380. })
  381. },
  382. //导入数据包
  383. handleImport() {
  384. this.$refs.projectImport.open()
  385. },
  386. //显示栏位管理
  387. handleField() {
  388. this.$refs.field.open(this.fieldList)
  389. },
  390. //操作列
  391. handleOption({ option, row ,isLast}) {
  392. switch (option) {
  393. case '0'://Excel导入
  394. this.patentImport(row,1)
  395. break
  396. case '1'://专利号导入
  397. this.patentImport(row,2)
  398. break
  399. case '2'://检索条件导入
  400. this.patentImport(row,4)
  401. break
  402. case '3'://任务清单
  403. this.taskList(row)
  404. break
  405. case '5'://报告管理
  406. this.reportFile(row)
  407. break
  408. case '6'://产品架构
  409. this.framework(row)
  410. break
  411. case '7'://事件
  412. break
  413. case '8'://其他附件
  414. this.otherFiles(row)
  415. break;
  416. case '9'://项目分享
  417. break;
  418. case '10'://删除
  419. this.deletes(row,isLast)
  420. break
  421. case 'e'://编辑
  422. this.handleEdit(row)
  423. break
  424. }
  425. },
  426. otherFiles(row){
  427. },
  428. //任务清单
  429. taskList(row){
  430. this.$router.push(
  431. {
  432. path:'/myTask',
  433. query:{
  434. projectId:row.id
  435. }
  436. }
  437. )
  438. },
  439. //报告文档
  440. reportFile(row){
  441. this.$router.push(
  442. {
  443. path:'/reportFiles',
  444. query:{
  445. projectId:row.id
  446. }
  447. }
  448. )
  449. },
  450. //架构
  451. framework(row){
  452. },
  453. //专利导入
  454. patentImport(row,type){
  455. var form = {
  456. importToId:row.id,
  457. importToType:0,
  458. type:type,
  459. ifUpdate:row.ifUpdate,
  460. crons:row.crons
  461. }
  462. this.$commonJS.toImportParent(form,type)
  463. },
  464. //获取删除的id
  465. deletes(row,isLast) {
  466. this.deletePatentProject([row.id],isLast)
  467. },
  468. //删除专利数据库
  469. deletePatentProject(ids) {
  470. this.$confirm('此操作将删除该产品类别, 是否继续?', '提示', {
  471. confirmButtonText: '确定',
  472. cancelButtonText: '取消',
  473. type: 'warning'
  474. }).then(() => {
  475. this.$api.deletePatentProject(ids).then(response => {
  476. if (response.code == 200) {
  477. this.handleMessage = '删除成功'
  478. this.$message.success('删除成功!');
  479. if (!this.group) {
  480. this.getList()
  481. }
  482. this.clearMessage()
  483. }
  484. })
  485. })
  486. },
  487. //编辑专利数据库
  488. handleEdit(row) {
  489. this.$refs.projectFormDrawer.open(JSON.parse(JSON.stringify(row)), '编辑专利数据库')
  490. },
  491. },
  492. };
  493. </script>
  494. <style lang="scss" scoped></style>
  495. <style lang="scss">
  496. .workspace {
  497. .workspace-card {
  498. min-height: calc(100% - 3px);
  499. // padding-bottom: 15px;
  500. .workspace-main {
  501. padding-top: 10px;
  502. width: 100%;
  503. }
  504. .el-card__body {
  505. height: 100%;
  506. }
  507. }
  508. .nopadding .el-card__body {
  509. padding: 0 !important;
  510. }
  511. .query-top {
  512. border-bottom: 1px solid #bbb;
  513. padding-bottom: 10px;
  514. .el-collapse {
  515. border-bottom: 0 !important;
  516. border-top: 0 !important;
  517. .el-collapse-item__wrap,
  518. .el-collapse-item__header {
  519. border-bottom: 0 !important;
  520. }
  521. .el-collapse-item__header {
  522. padding-left: 15px;
  523. font-weight: bold;
  524. }
  525. .is-active .el-collapse-item__wrap {
  526. border-top: 1px solid #bbb;
  527. }
  528. }
  529. .chart-box {
  530. height: 250px;
  531. }
  532. }
  533. }
  534. </style>