viewIndex.vue 12 KB

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