viewIndex.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <div class="patentMiningIndex">
  3. <el-container v-if="showView">
  4. <el-header>
  5. <div id="step1">
  6. <mySearch style="width:500px" :SearchFields="searchFiled" @search="search" :searchValue="searchOption"
  7. :disabled="!$permission('/workspace/project/check')"></mySearch>
  8. </div>
  9. <div style="display:flex;margin-right:10px">
  10. <div id="step2" v-if="[2].indexOf(isOperate) == -1">
  11. <span>分组查询:</span>
  12. <el-select v-model="group" :disabled="!$permission('/workspace/project/check')" clearable size="small"
  13. @change="onChange" style="width:200px">
  14. <el-option v-for="item in groupingOption" :key="item.value" :label="item.name" :value="item.value">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <el-button-group id="step3" class="margin-left_10" v-if="[2].indexOf(isOperate) == -1">
  19. <el-button :type="viewTypeBtn === 'commonTable' ? 'primary' : ''" @click="onChange2('commonTable')"
  20. size="small">列表</el-button>
  21. <el-button :type="viewTypeBtn === 'commonCard' ? 'primary' : ''" @click="onChange2('commonCard')"
  22. size="small">卡片</el-button>
  23. </el-button-group>
  24. <el-dropdown id="step4" trigger="click" split-button type="primary" size="small" @command="handleCommand($event)">
  25. <span @click="handleAdd">创建项目</span>
  26. <el-dropdown-menu slot="dropdown" class="text-align_center">
  27. <el-dropdown-item command="0">显示栏位管理</el-dropdown-item>
  28. </el-dropdown-menu>
  29. </el-dropdown>
  30. </div>
  31. </el-header>
  32. <el-main>
  33. <component v-if="showView" :is="viewType" v-bind="$attrs" v-on="$listeners" :isOperate="isOperate" :tableData="dataList"
  34. :column="columnList" :groupingOption="groupingOption" :groupBy="group" :queryParams="queryParams" @option="handleOption" @on-sort="handleSort"
  35. :commandData="commandData" :searchOption="searchOption" :handleMessage="handleMessage">
  36. </component>
  37. </el-main>
  38. <el-footer class="pagination">
  39. <div>
  40. <el-pagination background layout="total, prev, pager, next, jumper" :current-page.sync="queryParams.current"
  41. :page-size.sync="queryParams.size" @current-change="handleCurrentChange" :total="total">
  42. </el-pagination>
  43. </div>
  44. </el-footer>
  45. </el-container>
  46. <addAndEditProject ref="addAndEditProject" @isSuccess="isSuccess"></addAndEditProject>
  47. <fields ref="field" type="patentDigProject" @getFieldList="getFieldList"></fields>
  48. </div>
  49. </template>
  50. <script>
  51. import commonTable from './view/commonTable.vue';
  52. import commonCard from './view/card.vue';
  53. import addAndEditProject from './dialog/addAndEditProject.vue';
  54. import fields from '@/views/components/dialog/fields.vue';
  55. import mergeTable from '../components/view/MergeTable.vue'
  56. export default {
  57. components: {
  58. commonTable,
  59. addAndEditProject,
  60. fields,
  61. mergeTable,
  62. commonCard,
  63. },
  64. props: {
  65. isOperate: '',
  66. matterId:{},
  67. scenarioId:{},
  68. eventName:'',
  69. eventId:''
  70. },
  71. data() {
  72. return {
  73. //当前组件名称
  74. viewType: 'commonTable',
  75. // 当前按钮的底色
  76. viewTypeBtn:'commonTable',
  77. //专利挖掘项目table数据集合
  78. dataList: [],
  79. // 专利挖掘分组项目数据数组
  80. commandData:[],
  81. //分页
  82. queryParams: {
  83. size: 10,
  84. current: 1,
  85. },
  86. //当前分组的值
  87. group: '',
  88. // 分组字段数组
  89. groupingOption: [],
  90. //排序
  91. sort: [{ "orderBy": "createTime", "orderType": 1 }],
  92. //总数
  93. total: 0,
  94. //检索字段
  95. searchFiled: [
  96. {
  97. label: '项目名称',
  98. value: 'name',
  99. type: 1,
  100. placeholder: '请输入项目名称'
  101. },
  102. {
  103. label: '创建人',
  104. value: 'createPerson',
  105. type: 1,
  106. placeholder: '请输入创建人名称'
  107. },
  108. ],
  109. //检索条件
  110. searchOption: {
  111. scenarioNames:this.scenarioId,
  112. matterNames:this.matterId,
  113. name:localStorage.searchContent,
  114. eventNames:this.eventName
  115. },
  116. // table栏位信息
  117. columnList: [],
  118. //显示视图
  119. showView: false,
  120. // 子组件添加/更新项目返回的值
  121. handleMessage:'',
  122. };
  123. },
  124. watch: {},
  125. computed: {
  126. scene(){
  127. var a = this.$store.state.dictMessage.scenario.map(item=>{
  128. return {
  129. label:item.name,
  130. value:item.id
  131. }
  132. })
  133. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  134. if(obj){
  135. obj.options = a
  136. }
  137. return this.$store.state.dictMessage.scenario
  138. },
  139. matter() {
  140. var a = this.$store.state.dictMessage.matter.map(item => {
  141. return {
  142. label: item.name,
  143. value: item.id
  144. }
  145. })
  146. var obj = this.searchFiled.find(item => { return item.label == '调查类型' })
  147. if (obj) {
  148. obj.options = a
  149. }
  150. return this.$store.state.dictMessage.matter || []
  151. }
  152. },
  153. created() { },
  154. async mounted() {
  155. // 获取table栏位
  156. this.columnList = await this.$commonJS.getCustomField('patentDigProject')
  157. //获取检索、分组字段
  158. await this.getColumn()
  159. // 获取table数据
  160. this.getList()
  161. this.showViews()
  162. },
  163. methods: {
  164. //显示视图?
  165. showViews() {
  166. this.showView = false
  167. this.$nextTick(() => {
  168. this.showView = true
  169. })
  170. },
  171. //显示栏位管理
  172. getFieldList(data) {
  173. this.columnList = data
  174. },
  175. // 获取检索及分组栏位
  176. async getColumn() {
  177. let params = ['patentDigProject']
  178. await this.$api.getParamsCommon(params).then(res => {
  179. if (res.code == 200) {
  180. let conditionDTOList = JSON.parse(JSON.stringify(res.data[0].conditionDTOList))
  181. // 分组字段
  182. this.groupingOption = this.$commonJS.getField(conditionDTOList, (u) => u.ifGroup == true, {
  183. name: 'name',
  184. value: 'value',
  185. })
  186. // 检索字段
  187. this.searchFiled = this.$commonJS.getField(conditionDTOList, (u) => u.ifSearch == true, {
  188. label: 'name',
  189. value: 'value',
  190. type: 'type',
  191. })
  192. //为应用场景添加选项
  193. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  194. if(obj){
  195. obj.options = this.scene.map(item=>{
  196. return {
  197. label:item.name,
  198. value:item.id
  199. }
  200. })
  201. }
  202. var obj = this.searchFiled.find(item=>{return item.label == '调查类型'})
  203. if(obj){
  204. obj.options = this.matter.map(item=>{
  205. return {
  206. label:item.name,
  207. value:item.id
  208. }
  209. })
  210. }
  211. }
  212. })
  213. this.showViews()
  214. },
  215. // 新增、编辑成功信息
  216. isSuccess(val) {
  217. this.handleMessage = val
  218. this.queryParams.current = 1
  219. this.isGrouping()
  220. this.clearMessage()
  221. },
  222. clearMessage() {
  223. this.$emit('submit',true)
  224. this.$nextTick(() => {
  225. this.handleMessage = ''
  226. })
  227. },
  228. //获取检索组件传过来的数据
  229. search(val) {
  230. let params = {}
  231. val.forEach(item => {
  232. if (item.type == 3) {
  233. params[item.value] = item.searchValue.map(itemValue => {
  234. return itemValue.value
  235. })
  236. } else {
  237. params[item.value] = item.searchValue.label
  238. }
  239. })
  240. // 返回条件对象
  241. this.searchOption = params
  242. // 调用查询接口
  243. this.queryParams.current = 1
  244. this.getList()
  245. },
  246. //排序
  247. handleSort({ column, prop, order, str }) {
  248. //如需要多个字段排序,则不需要清空
  249. var params = {
  250. sort:this.sort,
  251. column,
  252. prop,
  253. order,
  254. }
  255. this.sort = this.$commonJS.getSortData(params)
  256. this.queryParams.current = 1
  257. //1表示展开行2表示基础表格
  258. if (str == '1') {
  259. this.getGrouping()
  260. } else {//table排序
  261. this.getList()
  262. }
  263. },
  264. //分页
  265. handleCurrentChange(val) {
  266. this.queryParams.current = val;
  267. this.isGrouping();
  268. },
  269. //获取专利挖掘项目数据列表
  270. getList() {
  271. let params = {
  272. ...this.queryParams,//分页信息
  273. searchQuery: this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  274. orderDTOList: this.sort,//排序
  275. }
  276. this.$api.queryPatentDigProject(params).then(res => {
  277. if (res.code == 200) {
  278. this.dataList = res.data.data
  279. this.total = res.data.total
  280. }
  281. }).catch(error => {
  282. this.dataList = []
  283. this.total = 0
  284. this.$message.error(error.message)
  285. })
  286. },
  287. // 获取分组数据
  288. getGrouping() {
  289. let params = {
  290. ...this.queryParams,//分页信息
  291. searchQuery: this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  292. orderDTOList: [
  293. {
  294. orderBy:this.group,
  295. orderType:this.sort.orderType
  296. }
  297. ],//排序
  298. groupBy: this.group,//分组的值
  299. }
  300. this.loading = true
  301. this.$api.groupPatentDigProject(params).then(response => {
  302. this.commandData = response.data.data.values
  303. this.total = response.data.total
  304. this.loading = false
  305. }).catch(error => {
  306. this.commandData = []
  307. this.total = 0
  308. this.loading = false
  309. })
  310. },
  311. //创建项目按钮,添加其他企业专利数据库
  312. handleAdd() {
  313. var form = {
  314. matterIds:this.matterId || [],
  315. scenarioIds:this.scenarioId || [],
  316. eventName:this.eventName,
  317. eventId:this.eventId
  318. }
  319. this.$refs.addAndEditProject.open()
  320. },
  321. // 创建项目按钮下拉菜单内容
  322. handleCommand(ev) {
  323. switch (ev) {
  324. case '0'://显示栏位管理
  325. this.$refs.field.open(this.columnList)
  326. break;
  327. default:
  328. break;
  329. }
  330. },
  331. //切换到分组
  332. onChange(val) {
  333. if (val != '') {
  334. this.viewType = 'mergeTable'
  335. } else {
  336. this.viewType = 'commonTable'
  337. }
  338. this.group = val
  339. this.queryParams.current = 1
  340. this.queryParams.size = 10
  341. this.isGrouping()//区分是否分组,调用不同请求数据
  342. },
  343. // 区分是否为分组
  344. isGrouping() {
  345. if (this.group != '') {//分组
  346. this.getGrouping()
  347. } else {//不分组
  348. this.getList()
  349. }
  350. },
  351. //切换视图
  352. onChange2(val) {
  353. this.viewType = val
  354. this.viewTypeBtn=val
  355. this.group=''
  356. this.queryParams.current = 1
  357. this.getList()
  358. },
  359. //操作列
  360. handleOption({ option, row ,isLast}) {
  361. switch (option) {
  362. case '0'://设置定时任务
  363. // this.$refs.addAndEditDB.open(row, true)
  364. break;
  365. case '1'://删除
  366. this.projectDelete(row,isLast)
  367. break;
  368. case 'e'://编辑
  369. this.$refs.addAndEditProject.open(row)
  370. break;
  371. }
  372. },
  373. // 删除项目
  374. projectDelete(row,isLast) {
  375. this.projectDeletes([row.id],isLast)
  376. },
  377. // 删除项目
  378. projectDeletes(ids, isLast) {
  379. this.$confirm('此操作将删除该项目, 是否继续?', '提示', {
  380. confirmButtonText: '确定',
  381. cancelButtonText: '取消',
  382. type: 'warning'
  383. }).then(() => {
  384. this.$api.deletePatentDigProject(ids).then(res => {
  385. if (res.code == 200) {
  386. this.handleMessage = '删除成功'
  387. if(isLast){
  388. this.isGrouping()
  389. }else{
  390. this.getList()
  391. }
  392. this.clearMessage()
  393. this.$message.success('删除成功!');
  394. }
  395. })
  396. }).catch(() => {
  397. this.$message.info('已取消删除');
  398. });
  399. },
  400. },
  401. };
  402. </script>
  403. <style lang="scss" scoped>
  404. .patentMiningIndex {
  405. height: 100%;
  406. }
  407. </style>