viewIndex.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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">
  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. },
  69. data() {
  70. return {
  71. //当前组件名称
  72. viewType: 'commonTable',
  73. // 当前按钮的底色
  74. viewTypeBtn:'commonTable',
  75. //专利挖掘项目table数据集合
  76. dataList: [],
  77. // 专利挖掘分组项目数据数组
  78. commandData:[],
  79. //分页
  80. queryParams: {
  81. size: 10,
  82. current: 1,
  83. },
  84. //当前分组的值
  85. group: '',
  86. // 分组字段数组
  87. groupingOption: [],
  88. //排序
  89. sort: [{ "orderBy": "createTime", "orderType": 1 }],
  90. //总数
  91. total: 0,
  92. //检索字段
  93. searchFiled: [
  94. {
  95. label: '项目名称',
  96. value: 'name',
  97. type: 1,
  98. placeholder: '请输入项目名称'
  99. },
  100. {
  101. label: '创建人',
  102. value: 'createPerson',
  103. type: 1,
  104. placeholder: '请输入创建人名称'
  105. },
  106. ],
  107. //检索条件
  108. searchOption: {
  109. scenarioNames:this.scenarioId,
  110. matterNames:this.matterId
  111. },
  112. // table栏位信息
  113. columnList: [],
  114. //显示视图
  115. showView: false,
  116. // 子组件添加/更新项目返回的值
  117. handleMessage:'',
  118. };
  119. },
  120. watch: {},
  121. computed: {
  122. scene(){
  123. var a = this.$store.state.dictMessage.scenario.map(item=>{
  124. return {
  125. label:item.name,
  126. value:item.id
  127. }
  128. })
  129. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  130. if(obj){
  131. obj.options = a
  132. }
  133. return this.$store.state.dictMessage.scenario
  134. },
  135. matter() {
  136. var a = this.$store.state.dictMessage.matter.map(item => {
  137. return {
  138. label: item.name,
  139. value: item.id
  140. }
  141. })
  142. var obj = this.searchFiled.find(item => { return item.label == '调查类型' })
  143. if (obj) {
  144. obj.options = a
  145. }
  146. return this.$store.state.dictMessage.matter || []
  147. }
  148. },
  149. created() { },
  150. async mounted() {
  151. // 获取table栏位
  152. this.columnList = await this.$commonJS.getCustomField('patentDigProject')
  153. //获取检索、分组字段
  154. await this.getColumn()
  155. // 获取table数据
  156. this.getList()
  157. this.showViews()
  158. },
  159. methods: {
  160. //显示视图?
  161. showViews() {
  162. this.showView = false
  163. this.$nextTick(() => {
  164. this.showView = true
  165. })
  166. },
  167. //显示栏位管理
  168. getFieldList(data) {
  169. this.columnList = data
  170. },
  171. // 获取检索及分组栏位
  172. async getColumn() {
  173. let params = ['patentDigProject']
  174. await this.$api.getParamsCommon(params).then(res => {
  175. if (res.code == 200) {
  176. let conditionDTOList = JSON.parse(JSON.stringify(res.data[0].conditionDTOList))
  177. // 分组字段
  178. this.groupingOption = this.$commonJS.getField(conditionDTOList, (u) => u.ifGroup == true, {
  179. name: 'name',
  180. value: 'value',
  181. })
  182. // 检索字段
  183. this.searchFiled = this.$commonJS.getField(conditionDTOList, (u) => u.ifSearch == true, {
  184. label: 'name',
  185. value: 'value',
  186. type: 'type',
  187. })
  188. //为应用场景添加选项
  189. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  190. if(obj){
  191. obj.options = this.scene.map(item=>{
  192. return {
  193. label:item.name,
  194. value:item.id
  195. }
  196. })
  197. }
  198. var obj = this.searchFiled.find(item=>{return item.label == '调查类型'})
  199. if(obj){
  200. obj.options = this.matter.map(item=>{
  201. return {
  202. label:item.name,
  203. value:item.id
  204. }
  205. })
  206. }
  207. }
  208. })
  209. this.showViews()
  210. },
  211. // 新增、编辑成功信息
  212. isSuccess(val) {
  213. this.handleMessage = val
  214. this.queryParams.current = 1
  215. this.isGrouping()
  216. this.clearMessage()
  217. },
  218. clearMessage() {
  219. this.$nextTick(() => {
  220. this.handleMessage = ''
  221. })
  222. },
  223. //获取检索组件传过来的数据
  224. search(val) {
  225. let params = {}
  226. val.forEach(item => {
  227. if (item.type == 3) {
  228. params[item.value] = item.searchValue.map(itemValue => {
  229. return itemValue.value
  230. })
  231. } else {
  232. params[item.value] = item.searchValue.label
  233. }
  234. })
  235. // 返回条件对象
  236. this.searchOption = params
  237. // 调用查询接口
  238. this.queryParams.current = 1
  239. this.getList()
  240. },
  241. //排序
  242. handleSort({ column, prop, order, str }) {
  243. //如需要多个字段排序,则不需要清空
  244. var params = {
  245. sort:this.sort,
  246. column,
  247. prop,
  248. order,
  249. }
  250. this.sort = this.$commonJS.getSortData(params)
  251. this.queryParams.current = 1
  252. //1表示展开行2表示基础表格
  253. if (str == '1') {
  254. this.getGrouping()
  255. } else {//table排序
  256. this.getList()
  257. }
  258. },
  259. //分页
  260. handleCurrentChange(val) {
  261. this.queryParams.current = val;
  262. this.isGrouping();
  263. },
  264. //获取专利挖掘项目数据列表
  265. getList() {
  266. let params = {
  267. ...this.queryParams,//分页信息
  268. searchQuery: this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  269. orderDTOList: this.sort,//排序
  270. }
  271. this.$api.queryPatentDigProject(params).then(res => {
  272. if (res.code == 200) {
  273. this.dataList = res.data.data
  274. this.total = res.data.total
  275. }
  276. }).catch(error => {
  277. this.dataList = []
  278. this.total = 0
  279. this.$message.error(error.message)
  280. })
  281. },
  282. // 获取分组数据
  283. getGrouping() {
  284. let params = {
  285. ...this.queryParams,//分页信息
  286. searchQuery: this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  287. orderDTOList: this.sort,//排序
  288. groupBy: this.group,//分组的值
  289. }
  290. this.loading = true
  291. this.$api.groupPatentDigProject(params).then(response => {
  292. this.commandData = response.data.data.values
  293. this.total = response.data.total
  294. this.loading = false
  295. }).catch(error => {
  296. this.commandData = []
  297. this.total = 0
  298. this.loading = false
  299. })
  300. },
  301. //创建项目按钮,添加其他企业专利数据库
  302. handleAdd() {
  303. this.$refs.addAndEditProject.open()
  304. },
  305. // 创建项目按钮下拉菜单内容
  306. handleCommand(ev) {
  307. switch (ev) {
  308. case '0'://显示栏位管理
  309. this.$refs.field.open(this.columnList)
  310. break;
  311. default:
  312. break;
  313. }
  314. },
  315. //切换到分组
  316. onChange(val) {
  317. if (val != '') {
  318. this.viewType = 'mergeTable'
  319. } else {
  320. this.viewType = 'commonTable'
  321. }
  322. this.group = val
  323. this.queryParams.current = 1
  324. this.queryParams.size = 10
  325. this.isGrouping()//区分是否分组,调用不同请求数据
  326. },
  327. // 区分是否为分组
  328. isGrouping() {
  329. if (this.group != '') {//分组
  330. this.getGrouping()
  331. } else {//不分组
  332. this.getList()
  333. }
  334. },
  335. //切换视图
  336. onChange2(val) {
  337. this.viewType = val
  338. this.viewTypeBtn=val
  339. this.group=''
  340. this.queryParams.current = 1
  341. this.getList()
  342. },
  343. //操作列
  344. handleOption({ option, row ,isLast}) {
  345. switch (option) {
  346. case '0'://设置定时任务
  347. // this.$refs.addAndEditDB.open(row, true)
  348. break;
  349. case '1'://删除
  350. this.projectDelete(row,isLast)
  351. break;
  352. case 'e'://编辑
  353. this.$refs.addAndEditProject.open(row)
  354. break;
  355. }
  356. },
  357. // 删除项目
  358. projectDelete(row,isLast) {
  359. this.projectDeletes([row.id],isLast)
  360. },
  361. // 删除项目
  362. projectDeletes(ids, isLast) {
  363. this.$confirm('此操作将删除该项目, 是否继续?', '提示', {
  364. confirmButtonText: '确定',
  365. cancelButtonText: '取消',
  366. type: 'warning'
  367. }).then(() => {
  368. this.$api.deletePatentDigProject(ids).then(res => {
  369. if (res.code == 200) {
  370. this.handleMessage = '删除成功'
  371. if(isLast){
  372. this.isGrouping()
  373. }else{
  374. this.getList()
  375. }
  376. this.clearMessage()
  377. this.$message.success('删除成功!');
  378. }
  379. })
  380. }).catch(() => {
  381. this.$message.info('已取消删除');
  382. });
  383. },
  384. },
  385. };
  386. </script>
  387. <style lang="scss" scoped>
  388. .patentMiningIndex {
  389. height: 100%;
  390. }
  391. </style>