LabelGroup.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div>
  3. <crumbs title="标签组维护" style="min-width: 980px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="标签类型:">
  6. <el-select size="mini" v-model="filter.tagType[0]" placeholder="标签类型" clearable>
  7. <el-option v-for="item in tagTypes" :label="item.name" :value="item.val" :key="item.id"></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="标签归属:">
  11. <el-select size="mini" v-model="filter.tagAdscription" @change="getValue" placeholder="标签归属" clearable>
  12. <el-option v-for="item in Adscriptions" :label="item.name" :value="item.val" :key="item.id" ></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="标签系统名称:">
  16. <el-input size="mini" v-model="filter.tagSysName" placeholder="标签系统名称" clearable></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="mini" @click="filterDatas">确认</el-button>
  20. <el-button size="mini" type="warning" @click="addTagGroup">添加标签组</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </crumbs>
  24. <div class="contents">
  25. <el-table
  26. :data="list"
  27. border
  28. style="width: 100%">
  29. <el-table-column
  30. :resizable = "false"
  31. type="index"
  32. :index = 'indexMethod'
  33. label="编号"
  34. width="60">
  35. </el-table-column>
  36. <el-table-column
  37. :resizable = "false"
  38. prop="gmtModified"
  39. label="操作时间"
  40. width="180">
  41. </el-table-column>
  42. <el-table-column
  43. :resizable = "false"
  44. prop="typeCn"
  45. label="标签归属">
  46. </el-table-column>
  47. <el-table-column
  48. :resizable = "false"
  49. prop="tagTypeCn"
  50. label="标签类型">
  51. </el-table-column>
  52. <el-table-column
  53. :resizable = "false"
  54. prop="tagName"
  55. label="标签系统名称">
  56. </el-table-column>
  57. <el-table-column
  58. :resizable = "false"
  59. label="标签名称是否存在于标准术语中">
  60. <template slot-scope="scope" >
  61. <span v-if="scope.row.itemType == 0">
  62. {{scope.row.exist ? "已存在" : "未存在"}}
  63. </span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. :resizable = "false"
  68. prop="modifier"
  69. label="操作人">
  70. </el-table-column>
  71. <el-table-column
  72. :resizable = "false"
  73. prop="operate"
  74. label="操作">
  75. <template slot-scope="scope">
  76. <el-button @click="modifyTagGroup(scope.row, 'modify')" type="text" size="small">修改</el-button>
  77. <span style="margin:0 3px;">|</span>
  78. <el-button @click="modifyTagGroup(scope.row, 'copy')" class="text" type="text" size="small">复制</el-button>
  79. <span style="margin:0 3px;">|</span>
  80. <el-button @click="showDelDialog(scope.row.id,scope.row.type)" class="delete" type="text" size="small">删除</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <div class="pagination">
  85. <el-pagination v-if="total>pageSize"
  86. :current-page.sync="currentPage"
  87. @current-change="currentChange"
  88. background
  89. :page-size="pageSize"
  90. layout="total,prev, pager, next, jumper"
  91. :total="total">
  92. </el-pagination>
  93. </div>
  94. </div>
  95. <!-- <div class="pagination">
  96. <el-pagination v-if="total>pageSize"
  97. :current-page.sync="currentPage"
  98. @current-change="currentChange"
  99. background
  100. :page-size="pageSize"
  101. layout="total,prev, pager, next, jumper"
  102. :total="total">
  103. </el-pagination>
  104. </div> -->
  105. </div>
  106. </template>
  107. <script>
  108. import api from '@api/icss.js';
  109. export default {
  110. name: 'tag-group',
  111. data: function() {
  112. return {
  113. list: [],
  114. tagTypes: [],
  115. Adscriptions: [], //标签归属列表
  116. tagTypesList: [], //标签类型列表
  117. searched: false,
  118. filter: {
  119. tagType: [], //标签类型
  120. tagAdscription: '', //标签归属
  121. tagSysName: '', //标签系统名称
  122. },
  123. currentPage: 1,
  124. pageSize: 10,
  125. total: 0,
  126. }
  127. },
  128. created() {
  129. this.getDropList().then(() => {
  130. this.getDataList()
  131. })
  132. },
  133. watch: {
  134. 'filter': {
  135. handler: function () {
  136. this.searched = false;
  137. },
  138. deep: true
  139. }
  140. },
  141. beforeRouteEnter(to, from, next) {
  142. next(vm => {
  143. //const pm = to.param;
  144. Object.assign(vm, to.params);
  145. })
  146. },
  147. methods: {
  148. getValue(val) {
  149. // console.log('changeVal', val, this.filter.tagAdscription)
  150. },
  151. getDropList() {
  152. return api.getDropList().then((res) =>{
  153. // console.log('dropList', res)
  154. if(res.data.code === '0') {
  155. // this.Adscriptions = res.data.data[1];
  156. let tmpLis = res.data.data[1]
  157. this.Adscriptions = tmpLis.filter(item => item.val != 7);
  158. this.tagTypes = res.data.data[2];
  159. for (var i = 0; i < this.tagTypes.length; i++) {
  160. this.tagTypesList.push(this.tagTypes[i].val)
  161. }
  162. }
  163. })
  164. },
  165. getDataList(isTurnPage) {
  166. const param = this.getFilterItems(isTurnPage);
  167. this.searched = true;
  168. api.getTagList(param).then((res) => {
  169. const list = res.data.data.records
  170. for (var i = 0; i < list.length; i++) {
  171. for (var j = 0; j < this.tagTypes.length; j++) {
  172. if(list[i].tagType == this.tagTypes[j].val) {
  173. list[i].tagTypeCn = this.tagTypes[j].name
  174. }
  175. }
  176. for (var z = 0; z < this.Adscriptions.length; z++) {
  177. if(list[i].type == this.Adscriptions[z].val) {
  178. list[i].typeCn = this.Adscriptions[z].name
  179. }
  180. }
  181. }
  182. this.list = list;
  183. this.total = res.data.data.total;
  184. })
  185. },
  186. filterDatas() {
  187. this.currentPage = 1;
  188. this.getDataList();
  189. },
  190. addTagGroup() {
  191. const pam = this.searched ? {
  192. currentPage: this.currentPage,
  193. filter: this.filter
  194. } : {currentPage: this.currentPage};
  195. this.$router.push({name: 'AddLabelGroup', params: pam});
  196. },
  197. modifyTagGroup(row, type) {
  198. api.detailsTag({id:row.id}).then((res)=>{
  199. const {code,data,msg} = res.data;
  200. if(code=='0'){
  201. const item = Object.assign({},row,data);
  202. const pam = this.searched ? {
  203. currentPage: this.currentPage,
  204. filter: this.filter
  205. } : {currentPage: this.currentPage};
  206. // console.log('item', item)
  207. if(type == 'modify') {
  208. this.$router.push({
  209. name: 'AddLabelGroup',
  210. params: Object.assign(pam, {isEdit: true, data: item})
  211. });
  212. } else if( type == 'copy') {
  213. this.$router.push({
  214. name: 'AddLabelGroup',
  215. params: Object.assign(pam, {isCopy: true, data: item})
  216. });
  217. } else {
  218. return
  219. }
  220. }else{
  221. this.$message({
  222. message: msg,
  223. type: 'warning'
  224. });
  225. }
  226. });
  227. },
  228. currentChange(next) {
  229. this.currentPage = next;
  230. this.getDataList(true);
  231. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  232. // this.list = this.cacheData[next];
  233. // } else {
  234. // this.getDataList();
  235. // }
  236. },
  237. getFilterItems(isTurnPage) {
  238. //翻页时筛选条件没点确定则清空
  239. if(isTurnPage&&!this.searched){
  240. this.clearFilter();
  241. };
  242. const param = {
  243. tagTypeList: this.filter.tagType[0] && this.filter.tagType|| this.tagTypesList,
  244. current: this.currentPage,
  245. size: this.pageSize,
  246. type: this.filter.tagAdscription,
  247. tagName: this.filter.tagSysName,
  248. notTypeList: [7]
  249. };
  250. return param;
  251. },
  252. indexMethod(index) {
  253. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  254. },
  255. getTagType(val) {
  256. return val
  257. },
  258. warning(msg,type){
  259. this.$message({
  260. showClose: true,
  261. message:msg,
  262. type:type||'warning'
  263. })
  264. },
  265. showConfirmDialog(msg,resolve){
  266. this.$alert(msg, '提示', {
  267. confirmButtonText: '确定',
  268. type: 'warning'
  269. }).then(() => {
  270. resolve();
  271. }).catch(() => {});
  272. },
  273. clearFilter(){
  274. this.filter={
  275. tagType: [], //标签类型
  276. tagAdscription: '', //标签归属
  277. tagSysName: '', //标签系统名称
  278. };
  279. },
  280. showDelDialog(id,type){
  281. this.showConfirmDialog('是否删除该标签组?',()=>{
  282. api.deleteTagGroup({ids:id,type:type}).then((res)=>{
  283. if(res.data.code=='0'){
  284. if(!this.searched){
  285. //未点确认时清空搜索条件
  286. this.clearFilter();
  287. }
  288. if(this.list.length==1){
  289. //当前在最后一页且只有一条数据时,删除后跳到前一页
  290. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  291. }
  292. this.getDataList();
  293. this.warning(res.data.msg || '操作成功','success');
  294. }else{
  295. this.warning(res.data.msg);
  296. }
  297. }).catch((error)=>{
  298. this.warning(error);
  299. })
  300. });
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="less">
  306. @import "../../less/admin.less";
  307. .delete{
  308. color: red;
  309. }
  310. .delete:hover {
  311. color: red;
  312. }
  313. .pagination {
  314. min-width: 1010px;
  315. }
  316. </style>