musicCourseFee.vue 15 KB

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