editionList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 版本控制
  6. </h2>
  7. <div class="m-core">
  8. <!-- -->
  9. <div
  10. class="newBand"
  11. @click="createEdi"
  12. v-permission="'appVersionInfo/add'"
  13. >
  14. 新建
  15. </div>
  16. <save-form :inline="true" @submit="search" :model="searchForm">
  17. <el-form-item label="客户端">
  18. <el-select clearable v-model="searchForm.search">
  19. <el-option
  20. v-for="(item, index) in sectionList"
  21. :key="index"
  22. :value="item.value"
  23. :label="item.label"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="danger" native-type="submit">搜索</el-button>
  29. </el-form-item>
  30. </save-form>
  31. <div class="tableWrap">
  32. <el-table
  33. :data="tableList"
  34. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  35. >
  36. <el-table-column
  37. align="center"
  38. prop="id"
  39. label="编号"
  40. ></el-table-column>
  41. <el-table-column align="center" prop="platform" label="客户端">
  42. <template slot-scope="scope">
  43. <div>{{ scope.row.platform | editionFilter }}</div>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. align="center"
  48. prop="version"
  49. label="版本号"
  50. ></el-table-column>
  51. <el-table-column align="center" prop="isForceUpdate" label="强制更新">
  52. <template slot-scope="scope">
  53. <div>{{ scope.row.isForceUpdate ? "是" : "否" }}</div>
  54. </template>
  55. </el-table-column>
  56. <el-table-column align="center" prop="status" label="状态">
  57. <template slot-scope="scope">
  58. <div>{{ scope.row.status | statusFilter }}</div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column align="center" prop="description" label="描述">
  62. <template slot-scope="scope">
  63. <overflow-text :text="scope.row.description"></overflow-text>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. align="center"
  68. prop="downloadUrl"
  69. width="120"
  70. label="下载链接"
  71. >
  72. <template slot-scope="scope">
  73. <overflow-text
  74. width="120px"
  75. :text="scope.row.downloadUrl"
  76. ></overflow-text>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="center" label="操作">
  80. <template slot-scope="scope">
  81. <div>
  82. <el-button
  83. v-permission="'appVersionInfo/update'"
  84. type="text"
  85. @click="resetEdit(scope.row)"
  86. >修改</el-button
  87. >
  88. </div>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <pagination
  93. sync
  94. :total.sync="rules.total"
  95. :page.sync="rules.page"
  96. :limit.sync="rules.limit"
  97. :page-sizes="rules.page_size"
  98. @pagination="getList"
  99. />
  100. </div>
  101. </div>
  102. <!-- v-if="sectionVisible" -->
  103. <el-dialog
  104. :title="isNew ? '版本添加' : '版本修改'"
  105. width="400px"
  106. :visible.sync="sectionVisible"
  107. v-if="sectionVisible"
  108. >
  109. <el-form
  110. :model="sectionForm"
  111. ref="sectionForm"
  112. :rules="sectionRules"
  113. label-position="right"
  114. label-width="80px"
  115. v-if="sectionVisible"
  116. >
  117. <el-form-item label="客户端" prop="platform" v-if="isNew">
  118. <el-select
  119. v-model="sectionForm.platform"
  120. style="width: 100% !important"
  121. clearable
  122. >
  123. <el-option
  124. v-for="(item, index) in sectionList"
  125. :key="index"
  126. :label="item.label"
  127. :value="item.value"
  128. ></el-option>
  129. </el-select>
  130. </el-form-item>
  131. <el-form-item label="版本号" prop="version" v-if="isNew">
  132. <el-input
  133. v-model.trim="sectionForm.version"
  134. @mousewheel.native.prevent
  135. ></el-input>
  136. </el-form-item>
  137. <el-form-item label="强制更新" prop="isForceUpdate">
  138. <el-select
  139. clearable
  140. style="width: 100% !important"
  141. v-model="sectionForm.isForceUpdate"
  142. >
  143. <el-option label="是" :value="true"></el-option>
  144. <el-option label="否" :value="false"></el-option>
  145. </el-select>
  146. </el-form-item>
  147. <el-form-item label="状态" prop="status">
  148. <el-select
  149. clearable
  150. style="width: 100% !important"
  151. v-model="sectionForm.status"
  152. >
  153. <el-option label="最新" value="newest"></el-option>
  154. <el-option label="历史" value="history"></el-option>
  155. </el-select>
  156. </el-form-item>
  157. <el-form-item label="下载链接" prop="downloadUrl">
  158. <el-input
  159. v-model.trim="sectionForm.downloadUrl"
  160. type="textarea"
  161. ></el-input>
  162. </el-form-item>
  163. <el-form-item label="描述" prop="description">
  164. <el-input
  165. type="textarea"
  166. v-model="sectionForm.description"
  167. ></el-input>
  168. </el-form-item>
  169. </el-form>
  170. <div slot="footer" class="dialog-footer">
  171. <el-button @click="sectionVisible=false">取 消</el-button>
  172. <el-button v-if="isNew" type="primary" @click="createEdition"
  173. >确 定</el-button
  174. >
  175. <el-button v-if="!isNew" type="primary" @click="resetEdition"
  176. >确 定</el-button
  177. >
  178. </div>
  179. </el-dialog>
  180. </div>
  181. </template>
  182. <script>
  183. import {
  184. appVersionInfo,
  185. addAppVersionInfo,
  186. resetAppVersionInfo,
  187. } from "@/api/systemManage";
  188. import pagination from "@/components/Pagination/index";
  189. import { decode } from "js-base64";
  190. export default {
  191. components: {
  192. pagination,
  193. },
  194. data() {
  195. return {
  196. sectionVisible: false,
  197. tableList: [],
  198. rules: {
  199. // 分页规则
  200. limit: 10, // 限制显示条数
  201. page: 1, // 当前页
  202. total: 0, // 总条数
  203. page_size: [10, 20, 40, 50], // 选择限制显示条数
  204. },
  205. searchForm: {
  206. search: null,
  207. },
  208. sectionList: [
  209. { value: "ios-teacher", label: "苹果-老师端" },
  210. { value: "ios-student", label: "苹果-学生端" },
  211. { value: "ios-education", label: "苹果-教务端" },
  212. { value: "android-teacher", label: "安卓-老师端" },
  213. { value: "android-student", label: "安卓-学生端" },
  214. { value: "android-education", label: "安卓-教务端" },
  215. ],
  216. sectionForm: {
  217. platform: "",
  218. version: "",
  219. isForceUpdate: "",
  220. downloadUrl: "",
  221. status: "",
  222. id: "",
  223. },
  224. sectionRules: {
  225. platform: [
  226. { required: true, message: "请选择客户端", trigger: "blur" },
  227. ],
  228. version: [{ required: true, message: "请输入版本号", trigger: "blur" }],
  229. isForceUpdate: [
  230. { required: true, message: "请选择是否强更", trigger: "blur" },
  231. ],
  232. status: [
  233. { required: true, message: "请选择版本状态", trigger: "blur" },
  234. ],
  235. },
  236. isNew: false,
  237. };
  238. },
  239. activated() {
  240. this.init();
  241. },
  242. created() {
  243. this.init();
  244. },
  245. methods: {
  246. search() {
  247. this.rules.page = 1;
  248. this.getList();
  249. },
  250. init() {
  251. this.getList();
  252. },
  253. getList() {
  254. this.searchForm.search
  255. ? this.searchForm.search
  256. : (this.searchForm.search = null);
  257. appVersionInfo({
  258. search: this.searchForm.search,
  259. page: this.rules.page,
  260. rows: this.rules.limit,
  261. }).then((res) => {
  262. if (res.code == 200) {
  263. this.tableList = res.data.rows.map((item) => ({
  264. ...item,
  265. downloadUrl: decode(item.downloadUrl || ""),
  266. }));
  267. this.rules.total = res.data.total;
  268. }
  269. });
  270. },
  271. createEdi() {
  272. this.isNew = true;
  273. this.sectionVisible = true;
  274. },
  275. createEdition() {
  276. this.$refs.sectionForm.validate((v) => {
  277. if (v) {
  278. addAppVersionInfo(this.sectionForm).then((res) => {
  279. if (res.code == 200) {
  280. this.$message.success("新增成功");
  281. this.sectionVisible = false;
  282. this.getList();
  283. }
  284. });
  285. }
  286. });
  287. },
  288. resetEdit(row) {
  289. this.isNew = false;
  290. this.$nextTick(() => {
  291. this.sectionForm = row;
  292. });
  293. this.sectionVisible = true;
  294. },
  295. resetEdition() {
  296. // 修改
  297. resetAppVersionInfo(this.sectionForm).then((res) => {
  298. if (res.code == 200) {
  299. this.$message.success("修改成功");
  300. this.sectionVisible = false;
  301. this.getList();
  302. }
  303. });
  304. },
  305. },
  306. filters: {
  307. statusFilter(val) {
  308. if (val == "newest") {
  309. return "最新";
  310. }
  311. if (val == "history") {
  312. return "历史";
  313. }
  314. return "";
  315. },
  316. },
  317. watch: {
  318. sectionVisible(val) {
  319. if (!val) {
  320. this.sectionForm = {
  321. platform: "",
  322. version: "",
  323. isForceUpdate: "",
  324. downloadUrl: "",
  325. status: "",
  326. id: "",
  327. };
  328. this.$refs["sectionForm"].resetFields();
  329. }
  330. },
  331. },
  332. };
  333. </script>
  334. <style lang="sass">
  335. </style>