VersionInfo.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div>
  3. <crumbs title="版本信息维护">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="版本号归属:">
  6. <el-select v-model="filter.type" placeholder="请选择" size="mini" clearable>
  7. <el-option
  8. v-for="item in typeList"
  9. :key="item.key"
  10. :label="item.name"
  11. :value="item.key">
  12. </el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="查询版本号:">
  16. <el-input size="mini" v-model="filter.name" placeholder="输入版本号"></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="mini" @click="filterDatas">确认</el-button>
  20. <!-- <router-link to="/admin/LT-YXSJWH-TJBBXX" style="margin:0 10px">
  21. <el-button size="mini" type="warning">添加版本信息</el-button>
  22. </router-link> -->
  23. <el-button size="mini" type="warning" style="margin:0 10px" @click="addVersion">添加版本信息</el-button>
  24. </el-form-item>
  25. </el-form>
  26. </crumbs>
  27. <div class="contents">
  28. <el-table :data="list"
  29. border
  30. style="width: 100%">
  31. <el-table-column
  32. type="index"
  33. :index="indexMethod"
  34. label="编号"
  35. width="60">
  36. </el-table-column>
  37. <el-table-column
  38. prop="gmtCreate"
  39. label="操作时间"
  40. :show-overflow-tooltip="true">
  41. </el-table-column>
  42. <el-table-column
  43. prop="name"
  44. label="版本号"
  45. show-overflow-tooltip>
  46. </el-table-column>
  47. <el-table-column
  48. prop="refreshTime"
  49. label="版本时间">
  50. </el-table-column>
  51. <el-table-column
  52. label="版本号归属">
  53. <template slot-scope="scope">
  54. <span>{{getProdType(scope.row)}}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="modifierid"
  59. label="操作人">
  60. </el-table-column>
  61. <el-table-column
  62. label="操作">
  63. <template slot-scope="scope">
  64. <!-- <el-button type="text" size="small" :class="{forbid:scope.row.id != canModiId}" @click="scope.row.id ==canModiId?toEditVersion(scope.row,false):''">修改</el-button> -->
  65. <el-button type="text" size="small" :class="{forbid:scope.row.status != 1}" @click="scope.row.status == 1?toEditVersion(scope.row,false):''">修改</el-button>
  66. <span style="margin:0 3px;">|</span>
  67. <el-button type="text" size="small" :class="{forbid:scope.row.status != 1}" @click="scope.row.status ==1?toEditVersion(scope.row,true):''">复制</el-button>
  68. </template>
  69. </el-table-column>
  70. <el-table-column
  71. label="详情">
  72. <template slot-scope="scope">
  73. <el-button type="text" size="small" @click="getDetail(scope.row)">详情</el-button>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. <el-pagination :current-page.sync="currentPage"
  78. @current-change="currentChange"
  79. background
  80. :page-size="pageSize"
  81. :page-sizes="pageSizeArr"
  82. @size-change="handleSizeChange"
  83. :layout="pageLayout"
  84. :total="total">
  85. </el-pagination>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import api from '@api/icss.js';
  91. import config from '@api/config.js';
  92. import utils from '@api/utils.js';
  93. export default {
  94. name: 'VersionInfo',
  95. data: function () {
  96. return {
  97. list: [],
  98. cacheData: {},
  99. currentPage: 1,
  100. pageSize: config.pageSize,
  101. pageSizeArr:config.pageSizeArr,
  102. pageLayout:config.pageLayout,
  103. total: 0,
  104. searched: false,
  105. filter: {
  106. name: '',
  107. type:null
  108. },
  109. canModiId:null, //标识列表中的第一个可修改和复制项,区分分页和搜索
  110. flag:true,
  111. typeList:[]
  112. }
  113. },
  114. created() {
  115. this.$nextTick(()=>{
  116. this.getDataList();
  117. let typeList = JSON.parse(localStorage.getItem("knowledgeEnumsData"));
  118. this.typeList = typeList.productTypeEnum;
  119. })
  120. },
  121. watch: {
  122. 'filter': {
  123. handler: function () {
  124. this.searched = false;
  125. },
  126. deep: true
  127. }
  128. },
  129. beforeRouteEnter(to, from, next) {
  130. next(vm => {
  131. //const pm = to.param;
  132. Object.assign(vm, to.params);
  133. })
  134. },
  135. methods: {
  136. handleSizeChange(val){
  137. this.pageSize = val;
  138. this.currentPage = utils.getCurrentPage(this.currentChange, this.total, this.pageSize);
  139. this.getDataList();
  140. },
  141. getProdType(item){
  142. let name = "";
  143. let type = item.productType;
  144. for(let i in this.typeList){
  145. if(this.typeList[i].key == type){
  146. name = this.typeList[i].name;
  147. }
  148. }
  149. return name;
  150. },
  151. addVersion(){
  152. // 添加版本信息
  153. const pam = this.searched ? {
  154. currentPage: this.currentPage,
  155. pageSize:this.pageSize,
  156. filter: this.filter
  157. } : {currentPage: this.currentPage,
  158. pageSize:this.pageSize};
  159. this.$router.push({
  160. name:'AddVersion',
  161. params: pam
  162. })
  163. },
  164. toEditVersion(row,flag){
  165. const pam = this.searched ? {
  166. currentPage: this.currentPage,
  167. pageSize:this.pageSize,
  168. filter: this.filter
  169. } : {currentPage: this.currentPage,
  170. pageSize:this.pageSize};
  171. this.$router.push({
  172. name:'AddVersion',
  173. params: Object.assign(pam, {info: row, copy: flag})
  174. })
  175. },
  176. filterDatas(){
  177. this.currentPage = 1;
  178. this.getDataList();
  179. },
  180. getDataList(isTurnPage) {
  181. const param = this.getFilterItems(isTurnPage);
  182. this.searched = true;
  183. const loading = this.$loading({
  184. lock: true,
  185. text: 'Loading',
  186. spinner: 'el-icon-loading',
  187. background: 'rgba(0, 0, 0, 0.7)'
  188. });
  189. api.versionInfo(param).then((res) => {
  190. loading.close()
  191. if (res.data.code == '0') {
  192. const data = res.data.data;
  193. this.list = data.records;
  194. this.cacheData[param.current] = data.records;
  195. this.total = data.total;
  196. if(this.flag){
  197. this.canModiId = this.list[0].id;
  198. }
  199. this.flag = false;
  200. }
  201. }).catch((error) => {
  202. console.log(error);
  203. });
  204. },
  205. getDetail(item) {//详情页内不能修改明细 4-11
  206. // let isFirst = item.id==this.list[0].id?true:false;
  207. let isFirst = false;
  208. this.$router.push({name:'VersionDetail', params:{info:item,isFirst}});
  209. },
  210. getFilterItems(isTurnPage) {
  211. //翻页时筛选条件没点确定则清空
  212. if(isTurnPage&&!this.searched){
  213. this.filter.name='';
  214. this.filter.type = null;
  215. };
  216. const param = {
  217. name: this.filter.name.trim(),
  218. current: this.currentPage,
  219. size: this.pageSize,
  220. productType:this.filter.type?this.filter.type:0
  221. };
  222. return param;
  223. },
  224. indexMethod(index) {
  225. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  226. },
  227. currentChange(next) {
  228. this.currentPage = next;
  229. if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  230. this.list = this.cacheData[next];
  231. } else {
  232. this.getDataList(true);
  233. }
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="less" scoped>
  239. @import "../../less/admin.less";
  240. .delete{
  241. color: red !important;
  242. }
  243. .forbid{
  244. color: #BFBFBF !important;
  245. }
  246. </style>