index.vue 15 KB

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