IndeptLabel.vue 11 KB

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