versionAdd.vue 20 KB

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