practiceRules.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div class="m-container">
  3. <!-- <h2>折扣设置</h2> -->
  4. <div v-if="(tableList.length>0 || pageInfo.page>1)&&contextFlag">
  5. <save-form
  6. :inline="true"
  7. @submit="search"
  8. @reset="onReSet"
  9. ref="searchForm"
  10. :saveKey="'practiceRules'"
  11. :model="searchForm"
  12. >
  13. <el-form-item prop="organId">
  14. <el-select
  15. placeholder="请选择分部"
  16. v-model="searchForm.organId"
  17. filterable
  18. clearable
  19. >
  20. <el-option
  21. v-for="(item, index) in selects.branchs"
  22. :label="item.name"
  23. :value="item.id"
  24. :key="index"
  25. ></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="danger" native-type="submit">搜索</el-button>
  30. <el-button native-type="reset" type="primary">重置</el-button>
  31. </el-form-item>
  32. </save-form>
  33. <el-button
  34. style="margin-bottom: 20px"
  35. type="primary"
  36. v-permission="'practiceGroupSellPrice/add'"
  37. @click="addPrice"
  38. icon="el-icon-plus"
  39. >添加</el-button
  40. >
  41. <!-- 列表 -->
  42. <div class="tableWrap">
  43. <el-table
  44. :data="tableList"
  45. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  46. >
  47. <el-table-column align="center" prop="organName" label="分部名称">
  48. </el-table-column>
  49. <el-table-column
  50. align="center"
  51. prop="singleClassMinutesPrice"
  52. label="网管课课时单价"
  53. >
  54. <template slot-scope="scope"
  55. >{{ scope.row.singleClassMinutesPrice }}元</template
  56. >
  57. </el-table-column>
  58. <el-table-column
  59. align="center"
  60. prop="comeOnPackagePrice"
  61. label="加油包课时总价"
  62. >
  63. <template slot-scope="scope"
  64. >{{ scope.row.comeOnPackagePrice }}元</template
  65. >
  66. </el-table-column>
  67. <el-table-column align="center" label="操作">
  68. <template slot-scope="scope">
  69. <el-button
  70. @click="openTypes(scope.row)"
  71. v-permission="'practiceGroupSellPrice/update'"
  72. type="text"
  73. >修改</el-button
  74. >
  75. <el-button
  76. @click="onTypesDel(scope.row)"
  77. v-permission="'practiceGroupSellPrice/del'"
  78. type="text"
  79. >删除</el-button
  80. >
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination
  85. :saveKey="'musicCourseFee'"
  86. sync
  87. :total.sync="pageInfo.total"
  88. :page.sync="pageInfo.page"
  89. :limit.sync="pageInfo.limit"
  90. :page-sizes="pageInfo.page_size"
  91. @pagination="getList"
  92. />
  93. </div>
  94. </div>
  95. <emptyPage @submit="addPrice" title='网管课收费设置' btnTitle='新建网管课收费设置' :context='context' v-if="!(tableList.length>0 || pageInfo.page>1)&&contextFlag" />
  96. <el-dialog
  97. :title="activeRow ? '修改' : '新建'"
  98. destroy-on-close
  99. :visible.sync="newVisiable"
  100. width="600px"
  101. >
  102. <el-form :model="createForm" class="createForm" ref="ruleForm">
  103. <el-form-item
  104. label="所属分部"
  105. :rules="[{ required: true, message: '所属分部', trigger: 'blur' }]"
  106. prop="organId"
  107. :label-width="formLabelWidth"
  108. >
  109. <el-select
  110. placeholder="请选择分部"
  111. v-model="createForm.organId"
  112. filterable
  113. clearable
  114. >
  115. <el-option
  116. v-for="(item, index) in selects.branchs"
  117. :label="item.name"
  118. :value="item.id"
  119. :key="index"
  120. ></el-option>
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item
  124. label="网管课课时单价"
  125. :label-width="formLabelWidth"
  126. :rules="[
  127. {
  128. required: true,
  129. message: '请输入每分钟课程费用',
  130. trigger: 'blur',
  131. },
  132. ]"
  133. :prop="`singleClassMinutesPrice`"
  134. >
  135. <el-input
  136. type="number"
  137. min="0"
  138. step="0.00000001"
  139. v-model="createForm.singleClassMinutesPrice"
  140. >
  141. <template slot="append">每分钟费用(元)</template>
  142. </el-input>
  143. </el-form-item>
  144. <el-form-item
  145. label="加油包课时总价"
  146. :label-width="formLabelWidth"
  147. :rules="[
  148. {
  149. required: true,
  150. message: '请输入每分钟课程费用',
  151. trigger: 'blur',
  152. },
  153. ]"
  154. prop="comeOnPackagePrice"
  155. >
  156. <el-input
  157. type="number"
  158. min="0"
  159. step="0.00000001"
  160. v-model="createForm.comeOnPackagePrice"
  161. >
  162. <template slot="append">每分钟费用(元)</template>
  163. </el-input>
  164. </el-form-item>
  165. </el-form>
  166. <span slot="footer" class="dialog-footer">
  167. <el-button @click="newVisiable = false">取 消</el-button>
  168. <el-button type="primary" @click="submitInfo">确 定</el-button>
  169. </span>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script>
  174. import pagination from "@/components/Pagination/index";
  175. import { getPracticePriceList, resetPracticePriceList,addPracticePriceList,delPracticePriceList } from "./api";
  176. import emptyPage from '@/components/emptyPage'
  177. export default {
  178. name: "practiceRules",
  179. components: { pagination,emptyPage },
  180. data() {
  181. return {
  182. newVisiable: false,
  183. resetVisible: false,
  184. tableList: [],
  185. dataList: [],
  186. organList: [],
  187. searchForm: {
  188. organId: null,
  189. courseScheduleType: null,
  190. },
  191. createForm: {
  192. organId: null,
  193. comeOnPackagePrice: null,
  194. singleClassMinutesPrice: null,
  195. },
  196. pageInfo: {
  197. // 分页规则
  198. limit: 10, // 限制显示条数
  199. page: 1, // 当前页
  200. total: 0, // 总条数
  201. page_size: [10, 20, 40, 50], // 选择限制显示条数
  202. },
  203. formLabelWidth: "120px",
  204. activeRow: null,
  205. context:'可根据不同分部设置不同的网管课课时和加油包课时单价,设置完成后,所选分部学员可在学生端APP以此价格自行购买网管课课程。加油包是由8节网管组成的课程组,用于为乐团训练中跟不上进度的学员单独辅导,每个学员仅有一次购买加油包的机会,且只可在后台为学员创建,设置单价时建议酌情优惠。',
  206. contextFlag:false
  207. };
  208. },
  209. mounted() {
  210. // 获取分部
  211. this.$store.dispatch("setBranchs");
  212. this.getList();
  213. },
  214. methods: {
  215. search() {
  216. this.pageInfo.page = 1;
  217. this.getList();
  218. },
  219. onReSet() {
  220. this.$refs.searchForm.resetFields();
  221. this.search();
  222. },
  223. async onTypesDel(row) {
  224. try {
  225. await this.$confirm("是否删除此条数据?", "提示", {
  226. confirmButtonText: "确定",
  227. cancelButtonText: "取消",
  228. type: "warning",
  229. });
  230. delPracticePriceList({ organId: row.organId }).then((res) => {
  231. this.$message.success('删除成功')
  232. this.getList()
  233. });
  234. } catch (error) {}
  235. },
  236. getList() {
  237. getPracticePriceList({
  238. rows: this.pageInfo.limit,
  239. page: this.pageInfo.page,
  240. organId: this.searchForm.organId,
  241. }).then((res) => {
  242. this.contextFlag = true
  243. let result = res.data;
  244. this.tableList = result.rows;
  245. this.pageInfo.total = result.total;
  246. // }
  247. });
  248. },
  249. submitInfo() {
  250. this.$refs.ruleForm.validate(async (valid) => {
  251. if (valid) {
  252. console.log(this.createForm)
  253. if (this.activeRow) {
  254. try {
  255. await resetPracticePriceList(this.createForm);
  256. this.$message.success("修改成功");
  257. this.getList();
  258. this.newVisiable = false;
  259. } catch (error) {}
  260. } else {
  261. try {
  262. await addPracticePriceList(this.createForm);
  263. this.$message.success("创建成功");
  264. this.getList();
  265. this.newVisiable = false;
  266. } catch (error) {console.log(error)}
  267. }
  268. }
  269. });
  270. },
  271. openTypes(row) {
  272. this.activeRow = row;
  273. this.createForm = {
  274. ...row,
  275. };
  276. this.newVisiable = true;
  277. },
  278. addPrice() {
  279. this.activeRow = null;
  280. this.$set(this, "createForm", {
  281. organId: null,
  282. comeOnPackagePrice: null,
  283. singleClassMinutesPrice: null,
  284. });
  285. this.newVisiable = true;
  286. },
  287. // resetSubmit() {
  288. // // resetOrganizationCourseUnitPrice
  289. // this.$refs.resetForm.validate(async (valid) => {
  290. // if (valid) {
  291. // }
  292. // });
  293. // },
  294. },
  295. };
  296. </script>
  297. <style lang="scss" scoped>
  298. /deep/.el-date-editor.el-input {
  299. width: 100% !important;
  300. }
  301. .el-select {
  302. // width: 100% !important;
  303. }
  304. .createForm {
  305. /deep/.el-input {
  306. width: 340px !important;
  307. }
  308. }
  309. </style>