VersionDesc.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="version-desc">
  3. <el-table v-if="list.length>0"
  4. :data="list"
  5. border
  6. style="width: 100%">
  7. <el-table-column
  8. type="index"
  9. :index="indexMethod"
  10. label="编号"
  11. width="60">
  12. </el-table-column>
  13. <el-table-column
  14. prop="gmtCreate"
  15. label="建立时间"
  16. :show-overflow-tooltip="true">
  17. </el-table-column>
  18. <el-table-column
  19. prop="modifierid"
  20. label="操作人">
  21. </el-table-column>
  22. <el-table-column v-if="isFirst"
  23. label="操作">
  24. <template slot-scope="scope">
  25. <el-button type="text" size="small" @click="toEditDesc(scope.row)">修改</el-button>
  26. <span style="margin:0 3px;">|</span>
  27. <el-button type="text" size="small" class="delete" @click="showDelDialog(scope.row.id)">删除</el-button>
  28. </template>
  29. </el-table-column>
  30. <el-table-column
  31. label="详情">
  32. <template slot-scope="scope">
  33. <el-button type="text" size="small" @click="getDetail(scope.row)">明细</el-button>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <el-button v-if="isFirst" class="disclButn" size="small" type="primary" @click="addDesc">+ 添加说明</el-button>
  38. <div class="boxMark" v-if="showBox">
  39. <el-form ref="form" :model="form" :rules="showDesc?{}:rules" label-width="65px" class="add-desc-form">
  40. <p class="top">
  41. {{minTitle}}
  42. <img src="../../images/close.png" height="12" width="12" @click="cancel">
  43. </p>
  44. <el-form-item label="标题:" prop="title">
  45. <p v-if="showDesc" class="cont">{{form.title}}</p>
  46. <el-input v-else v-model="form.title" placeholder="请输入标题" maxlength="30"></el-input>
  47. </el-form-item>
  48. <el-form-item label="内容:" prop="description" class="discDesc">
  49. <p v-if="showDesc" v-html="form.description" class="cont">{{form.description}}</p>
  50. <el-input v-else type="textarea" :rows="3" placeholder="请输入内容" v-model="form.description" maxlength="1024"></el-input>
  51. </el-form-item>
  52. <el-button class="disclButn" size="small" type="primary" @click="comfirn">确定</el-button>
  53. <!-- <el-button class="disclButn can" size="small" type="primary" @click="cancel">取消</el-button> -->
  54. </el-form>
  55. </div>
  56. </div>
  57. </template>
  58. <script type="text/javascript">
  59. import api from '@api/icss.js';
  60. export default {
  61. name:'VersionDesc',
  62. data(){
  63. const titleVaild = (rule, value, callback) => {
  64. if (!value) {
  65. return callback(new Error('请输入标题'));
  66. }
  67. if (value.length > 30) {
  68. this.form.name = value.substr(0, 120);
  69. this.$message({
  70. showClose: true,
  71. type: 'warning',
  72. message: '已超过最大字数限制'
  73. })
  74. }
  75. callback();
  76. };
  77. return{
  78. list:[],//版本说明列表
  79. form:{
  80. title:'',
  81. description:''
  82. },
  83. rules: {
  84. title:[
  85. { required: true, validator: titleVaild, trigger: ['blur', 'change'] },
  86. { required: true, message: '请输入标题', trigger: ['blur', 'change'] }
  87. ],
  88. description:[
  89. { required: true, message: '请输入内容', trigger: ['blur', 'change'] }
  90. ]
  91. },
  92. minTitle:'',
  93. showBox:false,
  94. modiId:null,
  95. showDesc:false
  96. }
  97. },
  98. created(){
  99. if(this.versionId){
  100. this.getList();
  101. }
  102. },
  103. props:['detail','versionId','isFirst'],
  104. methods:{
  105. getList(){
  106. api.getVersionDetlInfo({id:this.versionId}).then((res)=>{
  107. const result = res.data;
  108. if(result.code==0){
  109. this.list = result.data;
  110. }else{
  111. this.$message.error(result.msg);
  112. }
  113. })
  114. },
  115. indexMethod(index) {
  116. // return ((1 - 1) * 10) + index + 1;
  117. return index + 1;
  118. },
  119. toEditDesc(item){//修改备注
  120. console.log(124,item);
  121. this.minTitle='修改说明';
  122. this.showBox = true;
  123. this.form.title = item.title;
  124. this.form.description = item.description;
  125. this.modiId = item.id;
  126. },
  127. addDesc(){//添加备注
  128. this.minTitle='添加说明';
  129. this.showBox = true;
  130. },
  131. comfirn(){//记得清空modiId
  132. if(this.modiId){//修改
  133. const param = {
  134. title:this.form.title,
  135. description:this.form.description,
  136. detailId:this.modiId
  137. }
  138. api.modiVersionInfo(param).then((res)=>{
  139. if(res.data.code==0){
  140. this.$message({
  141. message:"添加成功",
  142. type:'success'
  143. })
  144. this.getList();
  145. }else{
  146. this.$message.error(res.data.msg);
  147. }
  148. })
  149. }else if(this.showDesc){//明细
  150. }else{//添加
  151. const params = {
  152. versionDetail: [
  153. {
  154. description: this.form.description,
  155. title: this.form.title,
  156. }
  157. ],
  158. versionInfoId: this.versionId
  159. }
  160. api.addVersionInfo(params).then((res)=>{
  161. if(res.data.code==0){
  162. this.$message({
  163. message:"添加成功",
  164. type:'success'
  165. })
  166. this.getList();
  167. }else{
  168. this.$message.error(res.data.msg);
  169. }
  170. })
  171. }
  172. this.reset();
  173. },
  174. reset(){//关闭弹窗复原数据
  175. this.showBox = false;
  176. this.showDesc = false;
  177. this.form.title = "";
  178. this.form.description = "";
  179. this.modiId = null;
  180. this.minTitle= "";
  181. },
  182. cancel(){
  183. this.reset();
  184. },
  185. getDetail(item){//明细
  186. this.minTitle='说明明细';
  187. this.showDesc = true;
  188. this.showBox = true;
  189. this.form.title = item.title;
  190. this.form.description = item.description;
  191. },
  192. warning(msg,type){
  193. this.$message({
  194. showClose: true,
  195. message:msg,
  196. type:type||'warning'
  197. })
  198. },
  199. showConfirmDialog(msg,resolve){
  200. this.$alert(msg, '提示', {
  201. confirmButtonText: '确定',
  202. type: 'warning'
  203. }).then(() => {
  204. resolve();
  205. }).catch(() => {});
  206. },
  207. showDelDialog(id){
  208. this.showConfirmDialog('是否删除该版本说明?',()=>{
  209. api.delVersionInfo({id}).then((res)=>{
  210. if(res.data.code=='0'){
  211. this.warning(res.data.msg||'操作成功','success');
  212. this.getList();
  213. }else{
  214. this.warning(res.data.msg);
  215. }
  216. }).catch((error)=>{
  217. this.warning(error);
  218. })
  219. });
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="less" >
  225. @import "../../less/admin.less";
  226. .disclButn{
  227. margin: 30px 0 10px;
  228. }
  229. .boxMark{
  230. position: fixed;
  231. top: 0;
  232. bottom: 0;
  233. left: 0;
  234. right: 0;
  235. text-align: center;
  236. // background: #808080;
  237. background-color:rgba(0,0,0,0.3);
  238. z-index: 1001;
  239. }
  240. // .el-form{
  241. .add-desc-form{
  242. width: 680px;
  243. position: absolute;
  244. top: 15%;
  245. left: 50%;
  246. // margin-top: -143px;
  247. margin-left: -340px;
  248. background: #fff;
  249. padding: 20px;
  250. max-height: 660px;
  251. overflow-y: auto;
  252. }
  253. .top{
  254. font-size: 15px;
  255. font-weight: bold;
  256. color: #545455;
  257. text-align: left;
  258. // padding-bottom: 10px;
  259. margin-bottom: 15px;
  260. // border-bottom: 1px solid #C9C9C9;
  261. position: relative;
  262. img{
  263. position: absolute;
  264. right: 5px;
  265. }
  266. }
  267. .can,.can:hover{
  268. background: #9B9B9B;
  269. border-color: #9B9B9B;
  270. }
  271. .cont{
  272. text-align: left;
  273. }
  274. .version-desc .el-table__body-wrapper{
  275. max-height: 340px;
  276. overflow-y: auto;
  277. }
  278. .version-desc .el-table th{
  279. padding: 0px;
  280. }
  281. </style>