versionAdd.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <div class="list_container">
  3. <div class="title_examine">
  4. <div class="pub_title">版本添加</div>
  5. <div style="margin-left: auto;"><el-button type="primary" size="small" @click="addVersionm()">新增版本</el-button>
  6. </div>
  7. </div>
  8. <!-- 内容区域 -->
  9. <div class="content">
  10. <!-- 按钮区域 -->
  11. <div class="button_top">
  12. <a @click="showType('正式')" :style="{ color: type == '正式' ? 'black' : 'rgb(179, 179, 179)' }">正式({{ countFormal
  13. }})</a>
  14. <a @click="showType('beta')" :style="{ color: type == 'beta' ? 'black' : 'rgb(179, 179, 179)' }">beta({{
  15. countBeta }})</a>
  16. <a @click="showType('hk')" :style="{ color: type == 'hk' ? 'black' : 'rgb(179, 179, 179)' }">hk({{ countHk
  17. }})</a>
  18. <a @click="showType('com')" :style="{ color: type == 'com' ? 'black' : 'rgb(179, 179, 179)' }">com({{ countCom
  19. }})</a>
  20. </div>
  21. <div class="tableBox">
  22. <el-table :data="tableData" stripe border style="width: 100%" :header-cell-style="headerCellStyle">
  23. <el-table-column show-overflow-tooltip prop="update_at" label="更新日期" min-width="45"></el-table-column>
  24. <el-table-column prop="update_title" label="更新标题" min-width="45" show-overflow-tooltip></el-table-column>
  25. <el-table-column prop="update_desc" label="更新描述" width="180px" class="description"></el-table-column>
  26. <el-table-column prop="update_details" label="更新详情" width="180px">
  27. <template #default="scope">
  28. <el-tooltip class="item" effect="dark" :content="scope.row.update_details" placement="top">
  29. <div class="cell-ellipsis">{{ scope.row.update_details }}</div>
  30. </el-tooltip>
  31. </template>
  32. </el-table-column>
  33. <el-table-column prop="update_version" label="更新版本" min-width="45"></el-table-column>
  34. <el-table-column prop="tagName" label="更新标签" min-width="45">
  35. <template #default="scope">
  36. <el-tooltip class="item" effect="dark" :content="scope.row.tagName" placement="top">
  37. <div class="cell-ellipsis">{{ scope.row.tagName }}</div>
  38. </el-tooltip>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="操作" width="150px">
  42. <template slot-scope="scope">
  43. <div class="operate" style="display: flex;gap: 24px;">
  44. <button style="color: #308fff;" @click="update(scope.row)">修改</button>
  45. <button style="color: #ff2570;" @click="delete_version(scope.row.id)">删除</button>
  46. <button style="color: rgb(21 189 97);" @click="go(scope.row)">预览</button>
  47. </div>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </div>
  52. <!-- 分页组件 -->
  53. <el-pagination :current-page="currentPage" :page-size="pageSize" :total="total" @current-change="handlePageChange"
  54. layout="total,prev, pager, next, jumper">
  55. </el-pagination>
  56. </div>
  57. <el-dialog title="新增版本" class="table" :visible.sync="isTableUseVisible" width="700px">
  58. <div>
  59. <form class="el-form">
  60. <div class="el-form-item">
  61. <label class="el-form-item__label">更新日期</label>
  62. <div class="el-form-item__content">
  63. <el-date-picker v-model="currentDate" format="yyyy-MM-dd" type="date" value-format="yyyy-MM-dd"
  64. placeholder="更新日期" />
  65. </div>
  66. </div>
  67. <div class="el-form-item">
  68. <label class="el-form-item__label">更新标题</label>
  69. <div class="el-form-item__content">
  70. <el-input placeholder="请输入标题" autocomplete="off" v-model="upTitle"></el-input>
  71. </div>
  72. </div>
  73. <div class="el-form-item">
  74. <label class="el-form-item__label">更新描述</label>
  75. <div class="el-form-item__content">
  76. <el-input type='textarea' placeholder="请输入描述" autocomplete="off" v-model="upDesc"
  77. :autosize="{ minRows: 2, maxRows: 10 }"></el-input>
  78. </div>
  79. </div>
  80. <div class="el-form-item">
  81. <label class="el-form-item__label">更新详情</label>
  82. <div class="el-form-item__content">
  83. <el-input type='textarea' placeholder="请输入详情" autocomplete="off" v-model="upDetail"
  84. :autosize="{ minRows: 2, maxRows: 10 }"></el-input>
  85. </div>
  86. </div>
  87. <div class="el-form-item">
  88. <label class="el-form-item__label">更新标签</label>
  89. <div class="el-form-item__content">
  90. <el-input v-model="newTag" placeholder="请输入标签,回车添加标签" autocomplete="off"
  91. @keyup.enter.native.prevent="addTag"></el-input>
  92. </div>
  93. <div class="tags-container">
  94. <el-tag v-for="(tag, index) in tags" :key="index" closable @close="removeTag(index)" class="tag-item">
  95. {{ tag }}
  96. </el-tag>
  97. </div>
  98. </div>
  99. <div class="el-form-item">
  100. <label class="el-form-item__label">版本分类</label>
  101. <div class="el-form-item__content">
  102. <el-select v-model="tagValue" placeholder="请选择">
  103. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.label">
  104. </el-option>
  105. </el-select>
  106. </div>
  107. </div>
  108. </form>
  109. </div>
  110. <!-- 按钮区域 -->
  111. <div slot="footer" class="el-dialog__footer">
  112. <el-button @click="isTableUseVisible = false;">取 消</el-button>
  113. <el-button type="primary" @click="addVersion()">确认</el-button>
  114. </div>
  115. </el-dialog>
  116. <el-dialog title="修改版本" class="table" :visible.sync="isTableUseVisible2" width="700px" @close="cancel()">
  117. <div>
  118. <form class="el-form">
  119. <div class="el-form-item">
  120. <label class="el-form-item__label">更新日期</label>
  121. <div class="el-form-item__content">
  122. <el-date-picker v-model="currentDate" format="yyyy-MM-dd" type="date" value-format="yyyy-MM-dd"
  123. placeholder="更新日期" />
  124. </div>
  125. </div>
  126. <div class="el-form-item">
  127. <label class="el-form-item__label">更新标题</label>
  128. <div class="el-form-item__content">
  129. <el-input placeholder="请输入标题" autocomplete="off" v-model="upTitle"></el-input>
  130. </div>
  131. </div>
  132. <div class="el-form-item">
  133. <label class="el-form-item__label">更新描述</label>
  134. <div class="el-form-item__content">
  135. <el-input type='textarea' placeholder="请输入描述" autocomplete="off" v-model="upDesc"
  136. :autosize="{ minRows: 2, maxRows: 10 }"></el-input>
  137. </div>
  138. </div>
  139. <div class="el-form-item">
  140. <label class="el-form-item__label">更新详情</label>
  141. <div class="el-form-item__content">
  142. <el-input type='textarea' placeholder="请输入详情" autocomplete="off" v-model="upDetail"
  143. :autosize="{ minRows: 2, maxRows: 10 }"></el-input>
  144. </div>
  145. </div>
  146. <div class="el-form-item">
  147. <label class="el-form-item__label">更新标签</label>
  148. <div class="el-form-item__content">
  149. <el-input v-model="newTag" placeholder="请输入标签,回车添加标签" autocomplete="off"
  150. @keyup.enter.native.prevent="addTag"></el-input>
  151. </div>
  152. <div class="tags-container">
  153. <el-tag v-for="(tag, index) in tags" :key="index" closable @close="removeTag(index)" class="tag-item">
  154. {{ tag }}
  155. </el-tag>
  156. </div>
  157. </div>
  158. <div class="el-form-item">
  159. <label class="el-form-item__label">版本分类</label>
  160. <div class="el-form-item__content">
  161. <el-select v-model="tagValue" placeholder="请选择">
  162. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.label">
  163. </el-option>
  164. </el-select>
  165. </div>
  166. </div>
  167. </form>
  168. </div>
  169. <!-- 按钮区域 -->
  170. <div slot="footer" class="el-dialog__footer">
  171. <el-button @click="isTableUseVisible2 = false">取 消</el-button>
  172. <el-button type="primary" @click="updateVersion()">确认</el-button>
  173. </div>
  174. </el-dialog>
  175. </div>
  176. </template>
  177. <script>
  178. import { API_CONFIG } from '@/common/apiConfig';
  179. import { mapGetters } from 'vuex';
  180. export default {
  181. name: 'versionAdd',
  182. data() {
  183. return {
  184. type: '正式',
  185. tableData: [],
  186. options: [{
  187. value: '选项1',
  188. label: '正式'
  189. }, {
  190. value: '选项2',
  191. label: 'beta'
  192. }, {
  193. value: '选项3',
  194. label: 'hk'
  195. }, {
  196. value: '选项4',
  197. label: 'com'
  198. }],
  199. tagValue: '',
  200. //新增版本
  201. isTableUseVisible: false,
  202. isTableUseVisible2: false,
  203. isPreviewVisible: false,
  204. upTitle: '',
  205. upDesc: '',
  206. upDetail: '',
  207. newTag: "", // 存储输入框的标签内容
  208. tags: [], // 存储已添加的标签
  209. nid: "",//修改的id
  210. currentDate: "",
  211. currentPage: 1,
  212. total: 0,
  213. pageSize: 10, // 每页显示的条目数
  214. countFormal: 0,
  215. countBeta: 0,
  216. countHk: 0,
  217. countCom: 0,
  218. isChong: 0
  219. }
  220. },
  221. computed: {
  222. ...mapGetters(["userid"]),
  223. },
  224. created() {
  225. this.formatDate();
  226. },
  227. methods: {
  228. go(row) {
  229. this.$router.push({
  230. path: '/versionInstr',
  231. query: {
  232. id: row.id,
  233. type: 2
  234. }
  235. });
  236. },
  237. formatDate() {
  238. // 使用示例
  239. const today = new Date(); // 获取当前日期
  240. const year = today.getFullYear(); // 获取年份
  241. const month = String(today.getMonth() + 1).padStart(2, '0'); // 获取月份,注意月份从0开始,所以要加1,并确保是两位数
  242. const day = String(today.getDate()).padStart(2, '0'); // 获取日期,并确保是两位数
  243. this.currentDate = `${year}-${month}-${day}`; // 返回格式化后的日期字符串
  244. },
  245. // 表头的背景色
  246. headerCellStyle() {
  247. return { backgroundColor: "#f1f1f1" };
  248. },
  249. showType(type) {
  250. this.type = type;
  251. this.currentPage = 1;
  252. this.getData()
  253. },
  254. addVersionm() {
  255. this.isTableUseVisible = true;
  256. },
  257. cancel() {
  258. this.formatDate();
  259. this.upTitle = '';
  260. this.upDesc = '';
  261. this.upDetail = '';
  262. this.tagValue = '';
  263. this.tags = [];
  264. },
  265. update(row) {
  266. this.isTableUseVisible2 = true;
  267. console.log("表格信息", row);
  268. this.currentDate = row.update_at;
  269. this.upTitle = row.update_title;
  270. this.upDesc = row.update_desc;
  271. this.upDetail = row.update_details;
  272. this.tagValue = row.update_version;
  273. this.tags = row.tagName ? row.tagName.split(',') : [];
  274. //修改后的数据
  275. this.nid = row.id;
  276. },
  277. // 添加标签
  278. addTag() {
  279. if (this.newTag.trim() !== '') {
  280. this.tags.push(this.newTag.trim());
  281. this.newTag = '';
  282. }
  283. },
  284. // 关闭预览对话框 清空tags
  285. handlePreviewClose() {
  286. this.tags = [];
  287. },
  288. // 删除标签
  289. removeTag(index) {
  290. this.tags.splice(index, 1); // 从标签数组中删除标签
  291. },
  292. getData() {
  293. let params = [
  294. {
  295. functionName: "getVersion",
  296. uid: this.userid,
  297. page: this.currentPage,
  298. num: this.pageSize,
  299. type: this.type
  300. }
  301. ];
  302. this.$ajax
  303. .post(API_CONFIG.baseUrl, params)
  304. .then((res) => {
  305. console.log("👉", res.data);
  306. this.tableData = res.data[0];
  307. this.total = res.data[0][0].num;
  308. this.countFormal = res.data[1][0].countFormal;
  309. this.countBeta = res.data[1][0].countBeta;
  310. this.countHk = res.data[1][0].countHk;
  311. this.countCom = res.data[1][0].countCom;
  312. })
  313. .catch((err) => {
  314. console.log(err);
  315. });
  316. },
  317. async addVersion() {
  318. if (this.upTitle === '') {
  319. this.$message.error("请填写标题");
  320. return;
  321. } else if (this.upDesc === '') {
  322. this.$message.error("请填写描述");
  323. return;
  324. } else if (this.upDetail === '') {
  325. this.$message.error("请填写详情");
  326. return;
  327. } else if (this.tags.length === 0) {
  328. this.$message.error("请填写标签");
  329. return;
  330. } else if (this.tagValue === '') {
  331. this.$message.error("请选择版本分类");
  332. return;
  333. }
  334. await this.versionChong();
  335. if (this.isChong === 1) {
  336. console.log(1);
  337. return;
  338. }
  339. this.isTableUseVisible = false;
  340. let params = [
  341. {
  342. functionName: "addVersion",
  343. uid: this.userid,
  344. upTime: this.currentDate,
  345. utitle: this.upTitle,
  346. udesc: this.upDesc,
  347. udetail: this.upDetail,
  348. uversion: this.tagValue,
  349. utags: this.tags.join(',')
  350. }
  351. ];
  352. this.$ajax
  353. .post(API_CONFIG.baseUrl, params)
  354. .then((res) => {
  355. console.log("👉", res.data);
  356. this.$message({
  357. message: '添加成功',
  358. type: 'success'
  359. });
  360. this.getData();
  361. this.upTitle = '';
  362. this.upDesc = '';
  363. this.upDetail = '';
  364. this.tagValue = '';
  365. this.tags = [];
  366. console.log(this.currentDate);
  367. this.formatDate()
  368. })
  369. .catch((err) => {
  370. this.$message.error("添加失败");
  371. console.log(err);
  372. });
  373. },
  374. // 页码扩展按钮
  375. handlePageChange(page) {
  376. this.currentPage = page;
  377. this.getData();
  378. },
  379. updateVersion() {
  380. if (this.upTitle === '') {
  381. this.$message.error("请填写标题");
  382. return;
  383. } else if (this.upDesc === '') {
  384. this.$message.error("请填写描述");
  385. return;
  386. } else if (this.upDetail === '') {
  387. this.$message.error("请填写详情");
  388. return;
  389. } else if (this.tags.length === 0) {
  390. this.$message.error("请填写标签");
  391. return;
  392. } else if (this.tagValue === '') {
  393. this.$message.error("请选择版本分类");
  394. return;
  395. }
  396. let params = [
  397. {
  398. functionName: "updateVersion",
  399. id: this.nid,
  400. ntitle: this.upTitle,
  401. ndesc: this.upDesc,
  402. ndetail: this.upDetail,
  403. ntags: this.tags,
  404. nversion: this.tagValue,
  405. ntime: this.currentDate
  406. }
  407. ];
  408. this.$ajax
  409. .post(API_CONFIG.baseUrl, params)
  410. .then((res) => {
  411. console.log("👉", res.data);
  412. this.isTableUseVisible2 = false;
  413. this.$message({
  414. message: '修改成功',
  415. type: 'success'
  416. });
  417. this.getData();
  418. })
  419. .catch((err) => {
  420. this.$message.error("修改失败");
  421. console.log(err);
  422. });
  423. },
  424. delete_version(id) {
  425. this.nid = id;
  426. let params = [
  427. {
  428. functionName: "deleteVersion",
  429. id: this.nid
  430. }
  431. ];
  432. this.$confirm("确定删除此版本记录吗?", "提示", {
  433. confirmButtonText: "确定",
  434. cancelButtonText: "取消",
  435. type: "warning",
  436. })
  437. .then(() => {
  438. this.$ajax
  439. .post(API_CONFIG.baseUrl, params)
  440. .then((res) => {
  441. console.log("👉", res.data);
  442. this.$message({
  443. message: '删除成功',
  444. type: 'success'
  445. });
  446. this.getData();
  447. })
  448. })
  449. .catch((err) => {
  450. this.$message.error("删除失败");
  451. console.log(err);
  452. });
  453. },
  454. async versionChong() {
  455. let params = [
  456. {
  457. functionName: "selectVersionChong",
  458. id: this.userid,
  459. ntime: this.currentDate,
  460. nversion: this.tagValue
  461. }
  462. ];
  463. await this.$ajax
  464. .post(API_CONFIG.baseUrl, params)
  465. .then((res) => {
  466. if (res.data[0][0].isChong === 1) {
  467. // 如果日期和版本已存在,提示用户
  468. this.$message.error("该日期在当前版本中已存在,请重新选择!");
  469. this.isChong = 1;
  470. console.log(res.data);
  471. }
  472. else {
  473. this.isChong = 0;
  474. }
  475. })
  476. .catch((err) => {
  477. // 处理请求错误
  478. console.error("检查日期和版本失败:", err);
  479. this.$message.error("检查日期和版本失败,请稍后重试!");
  480. });
  481. },
  482. },
  483. mounted() {
  484. this.getData();
  485. },
  486. }
  487. </script>
  488. <style scoped>
  489. .list_container {
  490. width: 100%;
  491. height: 100%;
  492. padding: 10px;
  493. box-sizing: border-box;
  494. overflow: auto;
  495. }
  496. /* 按钮区域 */
  497. .button_top {
  498. width: 100%;
  499. display: flex;
  500. align-items: center;
  501. margin: 10px 0;
  502. }
  503. .button_top a {
  504. cursor: pointer;
  505. color: black;
  506. font-weight: bold;
  507. }
  508. .button_top a+a {
  509. margin-left: 20px;
  510. }
  511. .table>>>.el-dialog__header {
  512. padding: 15px 20px;
  513. background: #454545;
  514. }
  515. .table>>>.el-dialog__title {
  516. color: #fff;
  517. }
  518. .tags-container {
  519. margin-top: 10px;
  520. }
  521. .el-tag {
  522. margin-right: 5px;
  523. }
  524. .el-form-item {
  525. display: flex;
  526. flex-direction: column;
  527. }
  528. .el-form-item__label {
  529. font-size: 14px;
  530. color: #606266;
  531. line-height: 40px;
  532. width: 70px;
  533. }
  534. .el-form-item__content {
  535. line-height: 40px;
  536. position: relative;
  537. font-size: 14px;
  538. }
  539. /* 分页功能的样式 */
  540. .el-pagination {
  541. /* 调整分页组件的顶部向上方距离50px */
  542. margin-top: 10px;
  543. padding: 0;
  544. }
  545. /* 设置分页按钮的宽度 */
  546. .el-pagination .el-pagination__prev,
  547. .el-pagination .el-pagination__next {
  548. width: 60px;
  549. /* 设置上一页和下一页按钮的宽度 */
  550. }
  551. /* 设置页码按钮的宽度 */
  552. .el-pagination .el-pager li {
  553. width: 50px;
  554. /* 设置每个页码按钮的宽度 */
  555. }
  556. /* 设置分页大小选择框的宽度 */
  557. .el-pagination .el-select {
  558. width: 80px;
  559. /* 设置分页大小选择框的宽度 */
  560. }
  561. .operate {
  562. display: flex;
  563. gap: 24px;
  564. }
  565. .operate button {
  566. background: none;
  567. border: none;
  568. cursor: pointer;
  569. }
  570. .version_middle {
  571. margin: 34px 45px;
  572. border-bottom: 1px solid #E7E7E7;
  573. padding-bottom: 25px;
  574. }
  575. .v_m_title {
  576. text-align: center;
  577. margin-bottom: 14px;
  578. font-size: 56px;
  579. }
  580. .v_m_instr {
  581. color: #00000099;
  582. display: -webkit-box;
  583. -webkit-box-orient: vertical;
  584. -webkit-line-clamp: 3;
  585. /* 限制显示的行数 */
  586. overflow: hidden;
  587. text-overflow: ellipsis;
  588. line-height: 24px;
  589. text-align: center;
  590. }
  591. .version_content {
  592. display: flex;
  593. margin: 39px 46px;
  594. ;
  595. }
  596. .v_l_items {
  597. display: flex;
  598. gap: 13px;
  599. flex-wrap: wrap;
  600. margin-top: 10px;
  601. }
  602. .v_l_item {
  603. padding: 2px 6px;
  604. background: rgb(240, 244, 255);
  605. color: rgb(51, 112, 255);
  606. border-radius: 4px;
  607. text-align: center;
  608. font-size: 14px;
  609. height: 20px;
  610. line-height: 20px;
  611. white-space: nowrap;
  612. /* 禁止换行 */
  613. overflow: hidden;
  614. /* 超出部分隐藏 */
  615. text-overflow: ellipsis;
  616. cursor: pointer;
  617. max-width: 165px;
  618. }
  619. .version_left {
  620. max-width: 232px;
  621. }
  622. .version_right {
  623. margin-left: 65px;
  624. }
  625. .v_r_text {
  626. margin-top: 10px;
  627. line-height: 35px;
  628. text-align: center;
  629. }
  630. .cell-ellipsis {
  631. white-space: nowrap;
  632. /* 禁止换行 */
  633. overflow: hidden;
  634. /* 超出部分隐藏 */
  635. text-overflow: ellipsis;
  636. /* 显示省略号 */
  637. }
  638. .tag-item {
  639. white-space: nowrap;
  640. /* 禁止换行 */
  641. overflow: hidden;
  642. /* 超出部分隐藏 */
  643. text-overflow: ellipsis;
  644. /* 显示省略号 */
  645. max-width: 200px;
  646. }
  647. </style>