index.vue 15 KB

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