musicCourseFee.vue 16 KB

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