musicCourseFee.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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="'musicCourseFee'"
  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 prop="courseScheduleType">
  29. <el-select
  30. placeholder="课程类型"
  31. v-model="searchForm.courseScheduleType"
  32. clearable
  33. filterable
  34. >
  35. <el-option
  36. v-for="(item, index) in musicCourseType"
  37. :label="item.label"
  38. :value="item.value"
  39. :key="index"
  40. ></el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="danger" native-type="submit">搜索</el-button>
  45. <el-button native-type="reset" type="primary">重置</el-button>
  46. </el-form-item>
  47. </save-form>
  48. <el-button
  49. style="margin-bottom: 20px"
  50. type="primary"
  51. v-permission="'organizationCourseUnitPriceSettings/save'"
  52. @click="newVisiable = true"
  53. icon="el-icon-plus"
  54. >添加</el-button
  55. >
  56. <!-- 列表 -->
  57. <div class="tableWrap">
  58. <el-table
  59. :data="tableList"
  60. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  61. >
  62. <el-table-column align="center" prop="organName" label="分部名称">
  63. <template slot-scope="scope">{{ scope.row.organ.name }}</template>
  64. </el-table-column>
  65. <el-table-column align="center" prop="courseType" label="课程类型">
  66. <template slot-scope="scope">{{
  67. scope.row.courseType | coursesType
  68. }}</template>
  69. </el-table-column>
  70. <el-table-column align="center" prop="chargeName" label="乐团类型">
  71. <template slot-scope="scope">{{
  72. scope.row.chargeType.name
  73. }}</template>
  74. </el-table-column>
  75. <el-table-column
  76. align="center"
  77. prop="goodsDiscountRate"
  78. label="每分钟费用"
  79. >
  80. <template slot-scope="scope">{{ scope.row.unitPrice }}</template>
  81. </el-table-column>
  82. <el-table-column align="center" prop="courseType" label="修改时间">
  83. <template slot-scope="scope">{{
  84. scope.row.updateTime | formatTimer
  85. }}</template>
  86. </el-table-column>
  87. <el-table-column align="center" label="操作">
  88. <template slot-scope="scope">
  89. <el-button
  90. @click="openTypes(scope.row)"
  91. v-permission="'organizationCourseUnitPriceSettings/update'"
  92. type="text"
  93. >修改</el-button
  94. >
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. :saveKey="'musicCourseFee'"
  100. sync
  101. :total.sync="pageInfo.total"
  102. :page.sync="pageInfo.page"
  103. :limit.sync="pageInfo.limit"
  104. :page-sizes="pageInfo.page_size"
  105. @pagination="getList"
  106. />
  107. </div>
  108. </div>
  109. <emptyPage @submit="newVisiable = true" title='乐团课价格设置' btnTitle='新建乐团课价格设置' :context='context' v-if="!(tableList.length>0 || pageInfo.page>1)&&contextFlag" />
  110. <el-dialog
  111. title="新建"
  112. destroy-on-close
  113. :visible.sync="newVisiable"
  114. width="600px"
  115. >
  116. <el-form :model="createForm" class="createForm" ref="ruleForm">
  117. <el-form-item
  118. label="所属分部"
  119. :rules="[{ required: true, message: '所属分部', trigger: 'blur' }]"
  120. prop="organId"
  121. :label-width="formLabelWidth"
  122. >
  123. <el-select
  124. placeholder="请选择分部"
  125. v-model="createForm.organId"
  126. @change="changeOrgan"
  127. filterable
  128. clearable
  129. >
  130. <el-option
  131. v-for="(item, index) in selects.branchs"
  132. :label="item.name"
  133. :value="item.id"
  134. :key="index"
  135. ></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item
  139. label="课程类型"
  140. :rules="[
  141. { required: true, message: '请选择课程类型', trigger: 'change' },
  142. ]"
  143. prop="courseType"
  144. :label-width="formLabelWidth"
  145. >
  146. <el-select
  147. v-model.trim="createForm.courseType"
  148. filterable
  149. placeholder="请选择课程类型"
  150. @change="changeCourseScheduleType"
  151. :disabled="!createForm.organId"
  152. clearable
  153. >
  154. <el-option
  155. v-for="item in musicCourseType"
  156. :key="item.value"
  157. :label="item.label"
  158. :value="item.value"
  159. >
  160. </el-option>
  161. </el-select>
  162. </el-form-item>
  163. <div v-for="(item, index) in dataList" :key="index">
  164. <el-form-item
  165. :label="`${item.name}`"
  166. :label-width="formLabelWidth"
  167. :rules="[
  168. {
  169. required: true,
  170. message: '请输入每分钟课程费用',
  171. trigger: 'blur',
  172. },
  173. ]"
  174. :prop="`unitPriceJson.${item.id}.price`"
  175. >
  176. <el-input
  177. type="number"
  178. min="0"
  179. step="0.00000001"
  180. v-model="createForm.unitPriceJson[item.id].price"
  181. >
  182. <template slot="append">每分钟费用(元)</template>
  183. </el-input>
  184. </el-form-item>
  185. </div>
  186. </el-form>
  187. <span slot="footer" class="dialog-footer">
  188. <el-button @click="newVisiable = false">取 消</el-button>
  189. <el-button type="primary" @click="submitInfo">确 定</el-button>
  190. </span>
  191. </el-dialog>
  192. <el-dialog
  193. title="修改"
  194. :visible.sync="resetVisible"
  195. width="500px"
  196. destroy-on-close
  197. >
  198. <el-form :model="resetForm" class="resetForm" ref="resetForm">
  199. <el-form-item
  200. label="所属分部"
  201. :rules="[{ required: true, message: '所属分部', trigger: 'blur' }]"
  202. prop="organId"
  203. :label-width="formLabelWidth"
  204. >
  205. <el-select
  206. placeholder="请选择分部"
  207. v-model="resetForm.organId"
  208. clearable
  209. disabled
  210. >
  211. <el-option
  212. v-for="(item, index) in selects.branchs"
  213. :label="item.name"
  214. :value="item.id"
  215. :key="index"
  216. ></el-option>
  217. </el-select>
  218. </el-form-item>
  219. <el-form-item
  220. label="课程类型"
  221. :rules="[
  222. { required: true, message: '请选择课程类型', trigger: 'blur' },
  223. ]"
  224. prop="courseType"
  225. :label-width="formLabelWidth"
  226. >
  227. <el-select
  228. v-model.trim="resetForm.courseType"
  229. filterable
  230. placeholder="请选择课程类型"
  231. clearable
  232. disabled
  233. >
  234. <el-option
  235. v-for="item in musicCourseType"
  236. :key="item.value"
  237. :label="item.label"
  238. :value="item.value"
  239. >
  240. </el-option>
  241. </el-select>
  242. </el-form-item>
  243. <el-form-item
  244. v-if="actvieRow"
  245. :label="`${actvieRow.chargeType.name}模式`"
  246. :label-width="formLabelWidth"
  247. :rules="[
  248. {
  249. required: true,
  250. message: '请输入每分钟课程费用',
  251. trigger: 'blur',
  252. },
  253. ]"
  254. prop="unitPrice"
  255. >
  256. <el-input
  257. type="number"
  258. min="0"
  259. step="0.00000001"
  260. v-model="resetForm.unitPrice"
  261. >
  262. <template slot="append">每分钟费用(元)</template>
  263. </el-input>
  264. </el-form-item>
  265. </el-form>
  266. <div slot="footer">
  267. <el-button @click="resetVisible = false">取 消</el-button>
  268. <el-button type="primary" @click="resetSubmit">确 定</el-button>
  269. </div>
  270. </el-dialog>
  271. </div>
  272. </template>
  273. <script>
  274. import pagination from "@/components/Pagination/index";
  275. import { getEmployeeOrgan } from "@/api/buildTeam";
  276. import emptyPage from '@/components/emptyPage'
  277. import {
  278. chargeTypeList,
  279. getOrganizationCourseUnitPriceSettings,
  280. addOrganizationCourseUnitPrice,
  281. resetOrganizationCourseUnitPrice,
  282. deleteOrganizationCourseUnitPrice,
  283. querySingle,
  284. } from "@/api/specialSetting";
  285. import createDiscount from "./modals/create-discount";
  286. import { musicCourseType } from "@/utils/searchArray";
  287. export default {
  288. name: "typesManager",
  289. components: { pagination, createDiscount,emptyPage },
  290. data() {
  291. return {
  292. musicCourseType,
  293. newVisiable: false,
  294. resetVisible: false,
  295. tableList: [],
  296. dataList: [],
  297. organList: [],
  298. searchForm: {
  299. organId: null,
  300. courseScheduleType: null,
  301. },
  302. createForm: {
  303. organId: null,
  304. courseType: null,
  305. unitPriceJson: {},
  306. },
  307. resetForm: {
  308. unitPrice: null,
  309. courseType: null,
  310. id: null,
  311. organId: null,
  312. },
  313. pageInfo: {
  314. // 分页规则
  315. limit: 10, // 限制显示条数
  316. page: 1, // 当前页
  317. total: 0, // 总条数
  318. page_size: [10, 20, 40, 50], // 选择限制显示条数
  319. },
  320. formLabelWidth: "120px",
  321. actvieRow: null,
  322. context:'系统支持不同分部在不同的乐团模式中设置各课程类型的不同价格标准,该标准为具体课程类型每分钟的收费价格,在创建乐团课程组合包或乐团临时加课时,根据组合包中的课程时长或临时加课的课程时长计算应该向学员收费的标准费用。创不以此标准价格创建学员缴费,则需要审核才可生效。',
  323. contextFlag:false
  324. };
  325. },
  326. mounted() {
  327. chargeTypeList({
  328. rows: 99999,
  329. page: 1,
  330. }).then((res) => {
  331. if (res.code == 200) {
  332. this.dataList = res.data.rows;
  333. this.dataList.forEach((item) => {
  334. this.$set(this.createForm.unitPriceJson, item.id, {price:null,id:null});
  335. });
  336. if (this.dataList.length <= 0) {
  337. this.$bus.$emit("showguide", ["teamPayType"]);
  338. return;
  339. }
  340. }
  341. });
  342. // 获取分部
  343. this.$store.dispatch("setBranchs");
  344. this.getList();
  345. },
  346. methods: {
  347. search() {
  348. this.pageInfo.page = 1;
  349. this.getList();
  350. },
  351. onReSet() {
  352. this.$refs.searchForm.resetFields();
  353. this.search();
  354. },
  355. async onTypesDel(row) {
  356. try {
  357. await this.$confirm("是否删除此条数据?", "提示", {
  358. confirmButtonText: "确定",
  359. cancelButtonText: "取消",
  360. type: "warning",
  361. });
  362. delChargeTypeSubjectMapper({ id: row.id }).then((res) => {
  363. this.messageTips("删除", res);
  364. });
  365. } catch (error) {}
  366. },
  367. getList() {
  368. getOrganizationCourseUnitPriceSettings({
  369. rows: this.pageInfo.limit,
  370. page: this.pageInfo.page,
  371. organId: this.searchForm.organId,
  372. courseScheduleType: this.searchForm.courseScheduleType,
  373. }).then((res) => {
  374. this.contextFlag = true
  375. let result = res.data;
  376. this.tableList = result.rows;
  377. this.pageInfo.total = result.total;
  378. // }
  379. });
  380. },
  381. submitInfo() {
  382. console.log(this.createForm);
  383. this.$refs.ruleForm.validate(async (valid) => {
  384. const data = [];
  385. for (const key in this.createForm.unitPriceJson) {
  386. if (this.createForm.unitPriceJson.hasOwnProperty(key)) {
  387. const item = this.createForm.unitPriceJson[key].price;
  388. const id = this.createForm.unitPriceJson[key].id
  389. data.push({
  390. chargeTypeId: key,
  391. courseType: this.createForm.courseType,
  392. organId: this.createForm.organId,
  393. unitPrice: item,
  394. id
  395. });
  396. }
  397. }
  398. if (valid) {
  399. try {
  400. await addOrganizationCourseUnitPrice(data);
  401. this.$message.success("创建成功");
  402. this.getList();
  403. this.newVisiable = false;
  404. this.createForm = {
  405. organId: null,
  406. courseType: null,
  407. unitPriceJson: {},
  408. };
  409. this.dataList.forEach((item) => {
  410. this.$set(this.createForm.unitPriceJson, item.id, {price:null,id:null});
  411. });
  412. } catch (error) {}
  413. }
  414. });
  415. },
  416. openTypes(row) {
  417. this.actvieRow = row;
  418. this.resetForm = {
  419. chargeTypeId: row.chargeTypeId,
  420. unitPrice: row.unitPrice,
  421. courseType: row.courseType,
  422. id: row.id,
  423. organId: row.organId,
  424. };
  425. this.resetVisible = true;
  426. },
  427. resetSubmit() {
  428. // resetOrganizationCourseUnitPrice
  429. this.$refs.resetForm.validate(async (valid) => {
  430. if (valid) {
  431. try {
  432. await resetOrganizationCourseUnitPrice(this.resetForm);
  433. this.$message.success("修改成功");
  434. this.getList();
  435. this.resetVisible = false;
  436. this.resetForm = {
  437. unitPrice: null,
  438. courseType: null,
  439. id: null,
  440. organId: null,
  441. };
  442. } catch (error) {}
  443. }
  444. });
  445. },
  446. changeCourseScheduleType(val) {
  447. if (val) {
  448. this.$refs.ruleForm.validateField("organId", async (flag) => {
  449. if (!flag) {
  450. try {
  451. const res = await querySingle(this.createForm.organId, val);
  452. //
  453. res.data.forEach((item) => {
  454. if (
  455. this.createForm.unitPriceJson.hasOwnProperty(
  456. item.chargeTypeId
  457. )
  458. ) {
  459. this.$set(
  460. this.createForm.unitPriceJson,
  461. item.chargeTypeId,
  462. {price:item.unitPrice,id:item.id}
  463. );
  464. }
  465. });
  466. this.$forceUpdate();
  467. } catch (e) {
  468. console.log(e);
  469. }
  470. }
  471. });
  472. }
  473. },
  474. changeOrgan(val) {
  475. if (val) {
  476. this.$refs.ruleForm.validateField("courseType", async (flag) => {
  477. if (!flag) {
  478. try {
  479. const res = querySingle(val, this.createForm.courseType);
  480. res.data.forEach((item) => {
  481. if (
  482. this.createForm.unitPriceJson.hasOwnProperty(
  483. item.chargeTypeId
  484. )
  485. ) {
  486. this.$set(
  487. this.createForm,
  488. unitPriceJson[item.chargeTypeId],
  489. item.unitPrice
  490. );
  491. }
  492. });
  493. } catch (e) {
  494. console.log(e);
  495. }
  496. }
  497. });
  498. }
  499. },
  500. },
  501. };
  502. </script>
  503. <style lang="scss" scoped>
  504. /deep/.el-date-editor.el-input {
  505. width: 100% !important;
  506. }
  507. .el-select {
  508. // width: 100% !important;
  509. }
  510. .createForm {
  511. /deep/.el-input {
  512. width: 340px !important;
  513. }
  514. }
  515. </style>