AppVersionManage.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="app-version-manage">
  3. <el-dialog
  4. class="page-dialog"
  5. :visible.sync="modalIsShow"
  6. title="应用版本管理"
  7. top="10px"
  8. width="1000px"
  9. :close-on-click-modal="false"
  10. :close-on-press-escape="false"
  11. append-to-body
  12. @opened="visibleChange"
  13. >
  14. <div class="part-box part-box-filter part-box-flex">
  15. <el-form
  16. ref="FilterForm"
  17. label-position="left"
  18. label-width="80px"
  19. inline
  20. >
  21. <el-form-item label="是否归档">
  22. <el-select
  23. v-model="filter.archived"
  24. placeholder="是否归档"
  25. clearable
  26. >
  27. <el-option
  28. v-for="(val, key) in ARCHIVED_TYPE"
  29. :key="key"
  30. :value="val"
  31. :label="val"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label-width="0px">
  36. <el-button type="primary" icon="ios-search" @click="toPage(1)"
  37. >查询</el-button
  38. >
  39. <el-button type="success" icon="md-add" @click="toAdd"
  40. >新增</el-button
  41. >
  42. </el-form-item>
  43. </el-form>
  44. </div>
  45. <div class="part-box part-box-pad">
  46. <el-table ref="TableList" :data="dataList">
  47. <el-table-column prop="id" label="ID" width="80"></el-table-column>
  48. <el-table-column prop="name" label="名称"> </el-table-column>
  49. <el-table-column prop="archived" label="是否为主干版本" width="80">
  50. <template slot-scope="scope">
  51. <span
  52. :class="{
  53. 'color-success': scope.row.id === curMasterVersionId
  54. }"
  55. ></span>
  56. {{ scope.row.id === curMasterVersionId ? "主干版本" : "" }}
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="archived" label="状态" width="80">
  60. <template slot-scope="scope">
  61. <span
  62. :class="scope.row.archived ? 'color-success' : 'color-info'"
  63. ></span>
  64. {{ scope.row.archived | archivedTypeFilter }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="createTime" label="创建时间" width="170">
  68. <span slot-scope="scope">{{
  69. scope.row.createTime | timestampFilter
  70. }}</span>
  71. </el-table-column>
  72. <el-table-column prop="updateTime" label="修改时间" width="170">
  73. <span slot-scope="scope">{{
  74. scope.row.updateTime | timestampFilter
  75. }}</span>
  76. </el-table-column>
  77. <el-table-column label="操作" width="100" class-name="action-column">
  78. <template slot-scope="scope">
  79. <el-button
  80. class="btn-primary"
  81. type="text"
  82. @click="toEdit(scope.row)"
  83. >编辑</el-button
  84. >
  85. <el-button
  86. class="btn-primary"
  87. type="text"
  88. :disabled="scope.row.id === curMasterVersionId"
  89. @click="toSetMaster(scope.row)"
  90. >设置为主干版本</el-button
  91. >
  92. <el-button
  93. :class="scope.row.archived ? 'btn-danger' : 'btn-primary'"
  94. type="text"
  95. @click="toArchived(scope.row)"
  96. >{{ scope.row.archived ? "取消归档" : "归档" }}</el-button
  97. >
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <div class="part-page">
  102. <el-pagination
  103. background
  104. layout="total,prev, pager, next"
  105. :current-page="current"
  106. :total="total"
  107. :page-size="size"
  108. @current-change="toPage"
  109. >
  110. </el-pagination>
  111. </div>
  112. </div>
  113. </el-dialog>
  114. <!-- ModifyAppVersion -->
  115. <modify-app-version
  116. ref="ModifyAppVersion"
  117. :instance="curRow"
  118. @modified="getList"
  119. ></modify-app-version>
  120. </div>
  121. </template>
  122. <script>
  123. import {
  124. appVersionList,
  125. appVersionInsertOrUpdate,
  126. appSetMasterVersion
  127. } from "../api";
  128. import { ARCHIVED_TYPE } from "../../../constants/enumerate";
  129. import ModifyAppVersion from "../components/ModifyAppVersion.vue";
  130. export default {
  131. name: "app-version-manage",
  132. components: { ModifyAppVersion },
  133. props: {
  134. app: {
  135. type: Object,
  136. default() {
  137. return {};
  138. }
  139. }
  140. },
  141. data() {
  142. return {
  143. modalIsShow: false,
  144. ARCHIVED_TYPE,
  145. filter: {
  146. archived: null
  147. },
  148. current: 1,
  149. size: this.GLOBAL.pageSize,
  150. total: 0,
  151. dataList: [],
  152. curRow: {},
  153. curMasterVersionId: null
  154. };
  155. },
  156. methods: {
  157. visibleChange() {
  158. this.curMasterVersionId = this.app.masterVertionId;
  159. // this.toPage(1);
  160. },
  161. cancel() {
  162. this.modalIsShow = false;
  163. },
  164. open() {
  165. this.modalIsShow = true;
  166. },
  167. async getList() {
  168. const datas = {
  169. ...this.filter,
  170. appId: this.app.id,
  171. pageNumber: this.current,
  172. pageSize: this.size
  173. };
  174. if (datas.archived !== null && datas.archived !== "")
  175. datas.archived = !!datas.archived;
  176. const data = await appVersionList(datas);
  177. this.dataList = data.records;
  178. this.total = data.total;
  179. },
  180. toPage(page) {
  181. this.current = page;
  182. this.getList();
  183. },
  184. toAdd() {
  185. this.curRow = { appId: this.app.id };
  186. this.$refs.ModifyAppVersion.open();
  187. },
  188. toEdit(row) {
  189. this.curRow = { ...row, appId: this.app.id };
  190. this.$refs.ModifyAppVersion.open();
  191. },
  192. async toSetMaster(row) {
  193. const confirm = await this.$confirm(
  194. `确定要设置版本号【${row.name}】为主干版本吗?`,
  195. "提示",
  196. {
  197. type: "warning"
  198. }
  199. ).catch(() => {});
  200. if (confirm !== "confirm") return;
  201. await appSetMasterVersion({
  202. appId: this.app.id,
  203. versionId: row.id
  204. });
  205. this.$message.success("操作成功!");
  206. this.curMasterVersionId = row.id;
  207. this.$emit("master-change");
  208. },
  209. async toArchived(row) {
  210. const action = row.archived ? "取消归档" : "归档";
  211. const confirm = await this.$confirm(
  212. `确定要${action}版本号【${row.name}】吗?`,
  213. "提示",
  214. {
  215. type: "warning"
  216. }
  217. ).catch(() => {});
  218. if (confirm !== "confirm") return;
  219. const archived = !row.archived;
  220. await appVersionInsertOrUpdate({
  221. id: row.id,
  222. archived
  223. });
  224. row.archived = archived;
  225. this.$message.success("操作成功!");
  226. }
  227. }
  228. };
  229. </script>