specialtyConfiguration.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!--专业类别-->
  2. <template>
  3. <div class="page-container basicConfiguration-specialtyConfiguration">
  4. <div class="top-box">
  5. <el-form class="add-form-box" :model="newData" ref="form" label-width="">
  6. <el-form-item label="" prop="disciplineName">
  7. <div style="display: flex">
  8. <el-input v-model="newData.disciplineName" placeholder="输入考试类型名称" maxLength="20" style="width:500px;"></el-input>
  9. <p class="form-button" @click="addButton()">+ 添加</p>
  10. </div>
  11. </el-form-item>
  12. </el-form>
  13. </div>
  14. <p class="title-p">专业类别名称</p>
  15. <div class="bottom-box scrollbar-box">
  16. <div class="for-box" v-for="(item,index) in dataList" :key="index">
  17. <div class="input-box" v-if="editorIndex === index">
  18. <el-input v-model="item.disciplineName" placeholder="输入考试类型名称"
  19. maxLength="20" style="flex:1;margin:10px 0 10px 5px;"></el-input>
  20. <p @click="confirmButton()">确定</p>
  21. </div>
  22. <div class="text-box" v-else>
  23. <p>{{item.disciplineName}}</p>
  24. <p @click="editorButton(index)">修改</p>
  25. <p @click="delButton(index)">删除</p>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. //import { getDicts } from "@/api/commonality/noPermission";
  33. //import { systemUserSelect } from "@/api/commonality/permission";
  34. //import { getInfo } from "@/api/basicsModules/index";
  35. import { examElDisciplineTypeList,examElDisciplineTypeBatchSave } from "@/api/safetyEducationExaminationNew/index";
  36. export default {
  37. name: 'specialtyConfiguration',
  38. props:{
  39. propsData:{},
  40. },
  41. data(){
  42. return{
  43. newData:{
  44. disciplineName:'',
  45. },
  46. dataList:[],
  47. editorIndex:null,
  48. }
  49. },
  50. created(){
  51. this.initialize();
  52. },
  53. mounted(){
  54. },
  55. methods:{
  56. initialize(){
  57. examElDisciplineTypeList({}).then(response => {
  58. this.$set(this,'dataList',response.data);
  59. });
  60. },
  61. //修改按钮
  62. editorButton(index){
  63. this.$set(this,'editorIndex',index);
  64. },
  65. //确定
  66. confirmButton(){
  67. if(!this.dataList[this.editorIndex].disciplineName){
  68. this.msgError('输入考试类型名称')
  69. return
  70. }
  71. this.$set(this,'editorIndex',null);
  72. },
  73. delButton(index){
  74. this.dataList.splice(index,1)
  75. },
  76. addButton(){
  77. if(!this.newData.disciplineName){
  78. this.msgError('输入考试类型名称')
  79. return
  80. }
  81. this.dataList.push({
  82. disciplineName:this.newData.disciplineName
  83. })
  84. this.$set(this.newData,'disciplineName','');
  85. },
  86. //重置
  87. resetButton(){
  88. let self = this;
  89. this.$confirm('确认重置?', "提示", {
  90. confirmButtonText: "确认",
  91. cancelButtonText: "取消",
  92. type: "warning"
  93. }).then(function() {
  94. }).then(() => {
  95. this.initialize();
  96. }).catch(() => {});
  97. },
  98. //提交
  99. submitButton(){
  100. let self = this;
  101. if(this.editorIndex!=null){
  102. this.msgError('请确认考试类型名称')
  103. return
  104. }
  105. this.$confirm('确认提交?', "提示", {
  106. confirmButtonText: "确认",
  107. cancelButtonText: "取消",
  108. type: "warning"
  109. }).then(function() {
  110. }).then(() => {
  111. let list = [];
  112. for(let i=0;i<self.dataList.length;i++){
  113. let obj = {
  114. id:self.dataList[i].id?self.dataList[i].id:'',
  115. disciplineName:self.dataList[i].disciplineName,
  116. }
  117. list.push(obj);
  118. }
  119. examElDisciplineTypeBatchSave(list).then(response => {
  120. self.msgSuccess(response.message);
  121. self.initialize();
  122. });
  123. }).catch(() => {});
  124. },
  125. },
  126. }
  127. </script>
  128. <style scoped lang="scss">
  129. .basicConfiguration-specialtyConfiguration{
  130. display: flex;
  131. flex-direction: column;
  132. flex:1;
  133. overflow: hidden;
  134. .top-box{
  135. height:60px;
  136. margin:20px 0 0 40px;
  137. .form-button{
  138. height:40px;
  139. line-height:38px;
  140. margin:0 0 0 10px;
  141. padding:0 20px;
  142. border-radius:4px;
  143. background-color: #0183fa;
  144. border:1px solid #0183fa;
  145. color:#fff;
  146. cursor: pointer;
  147. }
  148. }
  149. .title-p{
  150. width:600px;
  151. line-height:60px;
  152. //background-color: #dedede;
  153. border-bottom:1px solid #dedede;
  154. margin-left:40px;
  155. padding-left:20px;
  156. font-weight:600;
  157. }
  158. .bottom-box{
  159. flex:1;
  160. padding:0 20px 0 20px;
  161. .for-box{
  162. width:600px;
  163. border-bottom:1px solid #dedede;
  164. padding:0 20px 0 0;
  165. margin-left:20px;
  166. .text-box{
  167. display: flex;
  168. p{
  169. font-size:14px;
  170. }
  171. p:nth-child(1){
  172. flex:1;
  173. line-height:60px;
  174. font-weight:600;
  175. margin-left:20px;
  176. }
  177. p:nth-child(2){
  178. height:40px;
  179. line-height:38px;
  180. margin:10px 0 0 10px;
  181. padding:0 20px;
  182. border-radius:4px;
  183. background-color: #0183fa;
  184. border:1px solid #0183fa;
  185. color:#fff;
  186. cursor: pointer;
  187. }
  188. p:nth-child(3){
  189. height:40px;
  190. line-height:38px;
  191. margin:10px 0 0 10px;
  192. padding:0 20px;
  193. border-radius:4px;
  194. background-color: #fff;
  195. border:1px solid #999;
  196. color:#999;
  197. cursor: pointer;
  198. }
  199. }
  200. .input-box{
  201. display: flex;
  202. p{
  203. font-size:14px;
  204. }
  205. p:nth-child(1){
  206. flex:1;
  207. line-height:60px;
  208. }
  209. p:nth-child(2){
  210. height:40px;
  211. line-height:38px;
  212. margin:10px 0 0 10px;
  213. padding:0 20px;
  214. border-radius:4px;
  215. background-color: #FF6666;
  216. border:1px solid #FF6666;
  217. color:#fff;
  218. cursor: pointer;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </style>