vipParameterManager.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div> vip参数设置
  5. </h2>
  6. <div class="m-core">
  7. <div class="listWrap">
  8. <div class="left">
  9. <div class="newBand"
  10. @click="addGroupCategory">新建</div>
  11. <el-table :data='leftList'
  12. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  13. <el-table-column label="课程形式"
  14. prop="name"
  15. width="180">
  16. </el-table-column>
  17. <el-table-column label="班级人数"
  18. prop="studentNum"
  19. width="180">
  20. </el-table-column>
  21. <el-table-column label="课程课时"
  22. prop="singleClassMinutes"
  23. width="180">
  24. </el-table-column>
  25. <el-table-column label="操作"
  26. width="180">
  27. <template slot-scope="scope">
  28. <div>
  29. <el-button type="text"
  30. @click="resetGroupCategory(scope.row)">修改</el-button>
  31. <el-popover placement="top"
  32. width="160"
  33. :ref="scope.row.id">
  34. <p>您确定删除该课程形态吗?</p>
  35. <div style="text-align: right; margin: 0">
  36. <el-button size="mini"
  37. type="text"
  38. @click="scope._self.$refs[scope.row.id].doClose()">取消</el-button>
  39. <el-button type="primary"
  40. size="mini"
  41. @click="removeGroupCategory(scope)">确定</el-button>
  42. </div>
  43. <el-button type="text"
  44. slot="reference">删除</el-button>
  45. </el-popover>
  46. </div>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. </div>
  51. <div class="right">
  52. <div class="newBand"
  53. @click="addVipTimer">新建</div>
  54. <el-table :data='rightList'
  55. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  56. <el-table-column label="达到课时总数/次"
  57. prop="maxClassTimes"
  58. width="180">
  59. </el-table-column>
  60. <el-table-column label="可排课时间段"
  61. prop="month"
  62. width="180">
  63. </el-table-column>
  64. <el-table-column label="操作"
  65. width="180">
  66. <template slot-scope="scope">
  67. <div>
  68. <el-button type="text"
  69. @click="resetTimerList(scope.row)">修改</el-button>
  70. <el-popover placement="top"
  71. width="160"
  72. :ref="scope.row.id">
  73. <p>您确定删除该周期循环吗?</p>
  74. <div style="text-align: right; margin: 0">
  75. <el-button size="mini"
  76. type="text"
  77. @click="scope._self.$refs[scope.row.id].doClose()">取消</el-button>
  78. <el-button type="primary"
  79. size="mini"
  80. @click="removeDefaultClassesCycle(scope)">确定</el-button>
  81. </div>
  82. <el-button type="text"
  83. slot="reference">删除</el-button>
  84. </el-popover>
  85. </div>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 课程类型新增弹窗 -->
  93. <el-dialog title="vip课程形式"
  94. class="courseMask"
  95. width="500px"
  96. :visible.sync="vipStatus">
  97. <el-form :model="vipStatusFrom"
  98. ref='vipStatus'>
  99. <el-form-item label="课程形式"
  100. prop='name'
  101. :label-width="formLabelWidth">
  102. <el-input v-model="vipStatusFrom.name"
  103. autocomplete="off"></el-input>
  104. </el-form-item>
  105. <el-form-item label="班级人数"
  106. prop="num"
  107. :label-width="formLabelWidth">
  108. <el-input v-model="vipStatusFrom.num"
  109. autocomplete="off"></el-input>
  110. </el-form-item>
  111. <el-form-item label="课程课时"
  112. prop="timer"
  113. :label-width="formLabelWidth">
  114. <!-- <el-input v-model="vipStatusFrom.timer"
  115. autocomplete="off"></el-input> -->
  116. <el-tag :key="tag"
  117. effect="dark"
  118. type="info"
  119. v-for="tag in dynamicTags"
  120. closable
  121. :disable-transitions="false"
  122. @close="handleClose(tag)">
  123. {{tag}}
  124. </el-tag>
  125. <el-input class="input-new-tag"
  126. v-if="inputVisible"
  127. v-model="inputValue"
  128. ref="saveTagInput"
  129. style="width:100px;"
  130. size="small"
  131. @keyup.enter.native="handleInputConfirm">
  132. </el-input>
  133. <el-button v-if="!inputVisible"
  134. class="button-new-tag"
  135. size="small"
  136. @click="showInput">+ 添加</el-button>
  137. <el-button v-if="inputVisible"
  138. class="button-new-tag"
  139. size="small"
  140. @click="handleInputConfirm">保存</el-button>
  141. </el-form-item>
  142. </el-form>
  143. <div slot="footer"
  144. class="dialog-footer">
  145. <el-button @click="closeVipStatus">取 消</el-button>
  146. <el-button type="primary"
  147. @click="addVipStatus">确 定</el-button>
  148. </div>
  149. </el-dialog>
  150. <!-- 周期循环新增弹窗 -->
  151. <el-dialog title="vip时间段"
  152. width="500px"
  153. :visible.sync="timerStatus">
  154. <el-form :model="vipTimerFrom"
  155. ref='timerStatus'>
  156. <el-form-item label="达到课时总数/次"
  157. prop='count'
  158. :label-width="formLabelWidth">
  159. <el-input v-model="vipTimerFrom.count"
  160. autocomplete="off"></el-input>
  161. </el-form-item>
  162. <el-form-item label="可排课时间段/月"
  163. prop="timer"
  164. :label-width="formLabelWidth">
  165. <el-input v-model="vipTimerFrom.timer"
  166. autocomplete="off"></el-input>
  167. </el-form-item>
  168. </el-form>
  169. <div slot="footer"
  170. class="dialog-footer">
  171. <el-button @click="timerStatus=false">取 消</el-button>
  172. <el-button type="primary"
  173. @click="addTimerStatus">确 定</el-button>
  174. </div>
  175. </el-dialog>
  176. </div>
  177. </template>
  178. <script>
  179. import { vipGroupCategory, getDefaultClassesCycle, addVipGroupCategory, resetVipGroupCategory, removeVipGroupCategory, addDefaultClassesCycle, resetDefaultClassesCycle, removeDefaultClassesCycle } from "@/api/vipSeting"
  180. export default {
  181. data () {
  182. return {
  183. leftList: [],
  184. rightList: [],
  185. vipStatus: false, // 课程形态弹窗状态
  186. formLabelWidth: '120px',
  187. vipStatusFrom: {
  188. name: '',
  189. num: '',
  190. timer: [],
  191. isAdd: true,
  192. id: ''
  193. }, // 弹窗内容
  194. statusRemovevisible: false,
  195. timerStatus: false, //课程时间段弹窗状态
  196. vipTimerFrom: {
  197. count: '',
  198. timer: '',
  199. isAdd: true,
  200. id: ''
  201. },
  202. dynamicTags: [],
  203. inputVisible: false,
  204. inputValue: ''
  205. }
  206. },
  207. mounted () {
  208. this.getVipGroupCategoryList()
  209. this.getDefaultClassesCycle()
  210. },
  211. methods: {
  212. handleClose (tag) {
  213. this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
  214. },
  215. showInput () {
  216. this.inputVisible = true;
  217. this.$nextTick(_ => {
  218. this.$refs.saveTagInput.$refs.input.focus();
  219. });
  220. },
  221. handleInputConfirm () {
  222. let inputValue = this.inputValue;
  223. if (inputValue) {
  224. this.dynamicTags.push(inputValue);
  225. }
  226. this.inputVisible = false;
  227. this.inputValue = '';
  228. },
  229. getVipGroupCategoryList () {
  230. // 获取默认左边参数
  231. vipGroupCategory().then(res => {
  232. if (res.code == 200) {
  233. this.leftList = res.data;
  234. }
  235. })
  236. },
  237. getDefaultClassesCycle () {
  238. // 获取默认右边参数
  239. getDefaultClassesCycle().then(res => {
  240. this.rightList = res.data;
  241. })
  242. },
  243. // 新增分类
  244. addGroupCategory () {
  245. this.vipStatus = true;
  246. this.vipStatusFrom.isAdd = true;
  247. this.vipStatusFrom.id = '';
  248. this.vipStatusFrom.name = ''
  249. this.vipStatusFrom.num = ''
  250. this.dynamicTags = [];
  251. },
  252. closeVipStatus () {
  253. this.vipStatus = false;
  254. },
  255. addVipStatus () {
  256. // 点击添加后 发送请求单独添加=> 刷新列表
  257. // 判断是添加还是修改
  258. if (this.vipStatusFrom.isAdd) {
  259. // 添加
  260. addVipGroupCategory({
  261. name: this.vipStatusFrom.name,
  262. singleClassMinutes: this.dynamicTags.join(','),
  263. studentNum: this.vipStatusFrom.num
  264. }).then(res => {
  265. if (res.code == 200) {
  266. this.getVipGroupCategoryList();
  267. this.vipStatus = false;
  268. }
  269. })
  270. } else {
  271. // 修改
  272. resetVipGroupCategory({
  273. name: this.vipStatusFrom.name,
  274. singleClassMinutes: this.dynamicTags.join(','),
  275. studentNum: this.vipStatusFrom.num,
  276. id: this.vipStatusFrom.id
  277. }).then(res => {
  278. this.getVipGroupCategoryList();
  279. this.vipStatus = false;
  280. })
  281. }
  282. },
  283. resetGroupCategory (row) {
  284. // 修改课程形式
  285. this.vipStatus = true;
  286. this.vipStatusFrom.name = row.name;
  287. this.vipStatusFrom.timer = row.singleClassMinutes.split(',');
  288. this.dynamicTags = row.singleClassMinutes.split(',');
  289. this.vipStatusFrom.num = row.studentNum;
  290. this.vipStatusFrom.id = row.id;
  291. this.vipStatusFrom.isAdd = false;
  292. },
  293. removeGroupCategory (scope) {
  294. // 删除
  295. removeVipGroupCategory({
  296. id: scope.row.id
  297. }).then(res => {
  298. if (res.code == 200) {
  299. // scope._self.$refs[scope.$index].doClose();
  300. this.getVipGroupCategoryList();
  301. }
  302. })
  303. },
  304. // 新增时间段
  305. addVipTimer () {
  306. this.timerStatus = true;
  307. this.vipTimerFrom.isAdd = true;
  308. this.vipTimerFrom.id = '';
  309. },
  310. addTimerStatus () {
  311. // 点击添加后 发送请求单独添加=> 刷新列表
  312. // 判断是添加还是修改
  313. if (this.vipTimerFrom.isAdd) {
  314. // 添加
  315. addDefaultClassesCycle({
  316. organId: null,
  317. maxClassTimes: this.vipTimerFrom.count,
  318. month: this.vipTimerFrom.timer,
  319. }).then(res => {
  320. if (res.code == 200) {
  321. this.getDefaultClassesCycle();
  322. this.timerStatus = false;
  323. }
  324. })
  325. } else {
  326. // 修改
  327. resetDefaultClassesCycle({
  328. maxClassTimes: this.vipTimerFrom.count,
  329. month: this.vipTimerFrom.timer,
  330. id: this.vipTimerFrom.id
  331. }).then(res => {
  332. this.getDefaultClassesCycle();
  333. this.timerStatus = false;
  334. })
  335. }
  336. },
  337. resetTimerList (row) {
  338. this.timerStatus = true;
  339. this.vipTimerFrom.count = row.maxClassTimes;
  340. this.vipTimerFrom.timer = row.month;
  341. this.vipTimerFrom.id = row.id;
  342. this.vipTimerFrom.isAdd = false;
  343. },
  344. // 删除时间管理
  345. removeDefaultClassesCycle (scope) {
  346. removeDefaultClassesCycle({
  347. id: scope.row.id
  348. }).then(res => {
  349. if (res.code == 200) {
  350. scope._self.$refs[scope.row.id].doClose()
  351. this.getDefaultClassesCycle();
  352. }
  353. })
  354. },
  355. },
  356. watch: {
  357. vipStatus (val) {
  358. if (!val) {
  359. this.$refs['vipStatus'].resetFields();
  360. }
  361. },
  362. timerStatus (val) {
  363. if (!val) {
  364. this.$refs['timerStatus'].resetFields();
  365. }
  366. }
  367. }
  368. }
  369. </script>
  370. <style lang="scss" scoped>
  371. .left {
  372. margin-right: 20px;
  373. }
  374. .listWrap {
  375. display: flex;
  376. flex-direction: row;
  377. justify-content: flex-start;
  378. }
  379. </style>
  380. <style lang="scss">
  381. .courseMask {
  382. .el-tag.el-tag--info {
  383. margin-right: 4px;
  384. }
  385. }
  386. </style>