QualityControlTemp.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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="addTemp">添加模板</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 :current-page.sync="currentPage"
  88. @current-change="currentChange"
  89. background
  90. :page-size.sync="pageSize"
  91. :page-sizes="pageSizeArr"
  92. @size-change="handleSizeChange"
  93. :layout="pageLayout"
  94. :total="total">
  95. </el-pagination>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import api from '@api/icss.js';
  101. import config from '@api/config.js';
  102. export default {
  103. name: 'QualityControlTemp',
  104. data: function() {
  105. return {
  106. list: [],
  107. tagTypes: [],
  108. Adscriptions: [],
  109. tagTypesList:[],
  110. searched: false,
  111. filter: {
  112. tagType: [], //标签类型
  113. controlType: [],
  114. tagAdscription: '', //标签归属
  115. tagSysName: '', //标签系统名称
  116. },
  117. currentPage: 1,
  118. pageSize: config.pageSize,
  119. pageSizeArr:config.pageSizeArr,
  120. pageLayout:config.pageLayout,
  121. total: 0,
  122. }
  123. },
  124. created() {
  125. this.getDropList().then(() => {
  126. this.getDataList()
  127. })
  128. },
  129. watch: {
  130. 'filter': {
  131. handler: function () {
  132. this.searched = false;
  133. },
  134. deep: true
  135. }
  136. },
  137. beforeRouteEnter(to, from, next) {
  138. next(vm => {
  139. //const pm = to.param;
  140. Object.assign(vm, to.params);
  141. vm.inCurrentPage=to.params.currentPage;
  142. })
  143. },
  144. methods: {
  145. handleSizeChange(val){
  146. this.pageSize = val;
  147. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  148. this.getDataList();
  149. },
  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. const loading = this.$loading({
  166. lock: true,
  167. text: 'Loading',
  168. spinner: 'el-icon-loading',
  169. background: 'rgba(0, 0, 0, 0.7)'
  170. });
  171. api.getTagList(param).then((res) => {
  172. loading.close()
  173. const list = [...res.data.data.records];
  174. for (var i = 0; i < list.length; i++) {
  175. for (var j = 0; j < this.tagTypes.length; j++) {
  176. if(list[i].controlType == this.tagTypes[j].val) {
  177. list[i].tagTypeCn = this.tagTypes[j].name;
  178. }
  179. }
  180. //后台数据typeCn转换为筛选中对应的字段名称
  181. for (var z = 0; z < this.Adscriptions.length; z++) {
  182. if(list[i].type == this.Adscriptions[z].val) {
  183. list[i].typeCn = this.Adscriptions[z].name;
  184. }
  185. }
  186. }
  187. this.list = list;
  188. this.total = res.data.data.total;
  189. if(this.inCurrentPage!==undefined){
  190. this.currentPage=this.inCurrentPage;
  191. this.inCurrentPage = undefined;
  192. }
  193. })
  194. },
  195. filterDatas() {
  196. this.currentPage = 1;
  197. this.getDataList();
  198. },
  199. addTemp() {
  200. const pam = this.searched ? {
  201. currentPage: this.currentPage,
  202. pageSize:this.pageSize,
  203. filter: this.filter
  204. } : {currentPage: this.currentPage,pageSize:this.pageSize};
  205. this.$router.push({
  206. name: 'AddQualityControlTemp',
  207. params: pam
  208. })
  209. },
  210. modifyIndeptTag(row, type) {
  211. api.detailsTag({id:row.id}).then((res)=>{
  212. const {code,data,msg} = res.data;
  213. if(code=='0'){
  214. const item = Object.assign({},row,data);
  215. const pam = this.searched ? {
  216. currentPage: this.currentPage,
  217. filter: this.filter
  218. } : {currentPage: this.currentPage};
  219. if(type == 'modify') {
  220. this.$router.push({name: 'AddIndeptLabel', params: Object.assign(pam, {isEdit: true, data: item})});
  221. } else if( type == 'copy') {
  222. this.$router.push({name: 'AddIndeptLabel', params: Object.assign(pam, {isCopy: true, data: item})});
  223. } else {
  224. return
  225. }
  226. }else{
  227. this.$message({
  228. message: msg,
  229. type: 'warning'
  230. });
  231. }
  232. });
  233. //this.$router.push({name:'AddIndeptLabel',params:{isEdit:true,data:row}});
  234. },
  235. currentChange(next) {
  236. this.currentPage = next;
  237. this.getDataList(true);
  238. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  239. // this.list = this.cacheData[next];
  240. // } else {
  241. // this.getDataList();
  242. // }
  243. },
  244. clearFilter(){
  245. this.filter={
  246. tagType: [], //标签类型
  247. controlType: [],
  248. tagAdscription: '', //标签归属
  249. tagSysName: '', //标签系统名称
  250. };
  251. },
  252. getFilterItems(isTurnPage) {
  253. //翻页时筛选条件没点确定则清空
  254. if(isTurnPage&&!this.searched){
  255. this.clearFilter();
  256. };
  257. const param = {
  258. tagTypeList: [1],
  259. current: this.inCurrentPage||this.currentPage,
  260. size: this.pageSize,
  261. type: this.filter.tagAdscription,
  262. tagName: this.filter.tagSysName.trim(),
  263. controlTypeList: this.filter.controlType[0] ? this.filter.controlType: []
  264. };
  265. return param;
  266. },
  267. indexMethod(index) {
  268. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  269. },
  270. getTagType(val) {
  271. return val
  272. },
  273. warning(msg,type){
  274. this.$message({
  275. showClose: true,
  276. dangerouslyUseHTMLString: true,
  277. message:'<p>'+msg+'</p>',
  278. type:type||'warning'
  279. })
  280. },
  281. showConfirmDialog(msg,resolve){
  282. this.$alert(msg, '提示', {
  283. confirmButtonText: '确定',
  284. type: 'warning'
  285. }).then(() => {
  286. resolve();
  287. }).catch(() => {});
  288. },
  289. showDelDialog(row){
  290. const param = {
  291. "ids": row.id,
  292. "type": row.type
  293. }
  294. this.showConfirmDialog('是否删除该标签?',()=>{
  295. api.deleteTagGroup(param).then((res)=>{
  296. if(res.data.code=='0'){
  297. if(!this.searched){
  298. //未点确认时清空搜索条件
  299. this.clearFilter();
  300. }
  301. if(this.list.length==1){
  302. //当前在最后一页且只有一条数据时,删除后跳到前一页
  303. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  304. }
  305. this.getDataList();
  306. this.warning(res.data.msg || '操作成功','success');
  307. }else{
  308. this.warning(res.data.msg);
  309. }
  310. }).catch((error)=>{
  311. this.warning(error);
  312. })
  313. });
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="less">
  319. @import "../../less/admin.less";
  320. .delete{
  321. color: red
  322. }
  323. .delete:hover {
  324. color: red;
  325. }
  326. .el-select .el-input .el-icon-arrow-up{
  327. display: inline-block!important;
  328. }
  329. .el-select .el-input .el-icon-circle-close{
  330. float:left;
  331. }
  332. .el-pagination__sizes{
  333. margin-right: 20px;
  334. .el-input .el-input__inner{
  335. height: 28px;
  336. line-height: 28px;
  337. }
  338. }
  339. </style>