musicCourseFee.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div class="m-container">
  3. <!-- <h2>折扣设置</h2> -->
  4. <div class="m-core">
  5. <el-form :inline="true"
  6. :model="searchForm">
  7. <el-form-item>
  8. <el-select placeholder="请选择分部"
  9. v-model="searchForm.organId"
  10. clearable>
  11. <el-option v-for="(item, index) in organList"
  12. :label="item.name"
  13. :value="item.id"
  14. :key="index"></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-select placeholder="课程类型"
  19. v-model="searchForm.courseScheduleType"
  20. clearable
  21. filterable>
  22. <el-option v-for="(item, index) in musicCourseType"
  23. :label="item.label"
  24. :value="item.value"
  25. :key="index"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="danger"
  30. @click="search">搜索</el-button>
  31. <el-button @click="onReSet"
  32. type="primary">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <div class="newBand"
  36. v-permission="'organizationCourseUnitPriceSettings/insert'"
  37. @click="newVisiable = true">
  38. 添加
  39. </div>
  40. <!-- 列表 -->
  41. <div class="tableWrap">
  42. <el-table :data="tableList"
  43. :header-cell-style="{ background: '#EDEEF0', color: '#444' }">
  44. <el-table-column align="center"
  45. prop="organName"
  46. label="分部名称">
  47. <template slot-scope="scope">{{ scope.row.organ.name }}</template>
  48. </el-table-column>
  49. <el-table-column align="center"
  50. prop="courseType"
  51. label="课程类型">
  52. <template slot-scope="scope">{{
  53. scope.row.courseType | coursesType
  54. }}</template>
  55. </el-table-column>
  56. <el-table-column align="center"
  57. prop="chargeName"
  58. label="缴费形态">
  59. <template slot-scope="scope">{{
  60. scope.row.chargeType.name
  61. }}</template>
  62. </el-table-column>
  63. <el-table-column align="center"
  64. prop="goodsDiscountRate"
  65. label="缴费金额">
  66. <template slot-scope="scope">{{
  67. scope.row.unitPrice
  68. }}</template>
  69. </el-table-column>
  70. <el-table-column align="center"
  71. prop="courseType"
  72. label="修改时间">
  73. <template slot-scope="scope">{{
  74. scope.row.updateTime | formatTimer
  75. }}</template>
  76. </el-table-column>
  77. <el-table-column align="center"
  78. label="操作">
  79. <template slot-scope="scope">
  80. <el-button @click="openTypes(scope.row)"
  81. v-permission="'organizationCourseUnitPriceSettings/update'"
  82. type="text">修改</el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <pagination :total="pageInfo.total"
  87. :page.sync="pageInfo.page"
  88. :limit.sync="pageInfo.limit"
  89. :page-sizes="pageInfo.page_size"
  90. @pagination="getList" />
  91. </div>
  92. </div>
  93. <el-dialog title="新建"
  94. destroy-on-close
  95. :visible.sync="newVisiable"
  96. width="500px">
  97. <el-form :model="createForm"
  98. class="createForm"
  99. ref="ruleForm">
  100. <el-form-item label="所属分部"
  101. :rules="[{ required: true, message: '所属分部', trigger: 'blur' }]"
  102. prop="organId"
  103. :label-width="formLabelWidth">
  104. <el-select placeholder="请选择分部"
  105. v-model="createForm.organId"
  106. clearable>
  107. <el-option v-for="(item, index) in organList"
  108. :label="item.name"
  109. :value="item.id"
  110. :key="index"></el-option>
  111. </el-select>
  112. </el-form-item>
  113. <el-form-item label="课程类型"
  114. :rules="[
  115. { required: true, message: '请选择课程类型', trigger: 'blur' },
  116. ]"
  117. prop="courseType"
  118. :label-width="formLabelWidth">
  119. <el-select v-model.trim="createForm.courseType"
  120. filterable
  121. placeholder="请选择课程类型"
  122. clearable>
  123. <el-option v-for="item in musicCourseType"
  124. :key="item.value"
  125. :label="item.label"
  126. :value="item.value">
  127. </el-option>
  128. </el-select>
  129. </el-form-item>
  130. <div v-for="(item, index) in dataList"
  131. :key="index">
  132. <el-form-item :label="`${item.name}模式`"
  133. :label-width="formLabelWidth"
  134. :rules="[
  135. {
  136. required: true,
  137. message: '请输入每分钟课程费用',
  138. trigger: 'blur',
  139. },
  140. ]"
  141. :prop="`unitPriceJson.${item.id}`">
  142. <el-input type="number"
  143. min="0"
  144. step="0.00000001"
  145. v-model="createForm.unitPriceJson[item.id]">
  146. <template slot="append">每分钟费用(元)</template>
  147. </el-input>
  148. </el-form-item>
  149. </div>
  150. </el-form>
  151. <span slot="footer"
  152. class="dialog-footer">
  153. <el-button @click="newVisiable = false">取 消</el-button>
  154. <el-button type="primary"
  155. @click="submitInfo">确 定</el-button>
  156. </span>
  157. </el-dialog>
  158. <el-dialog title="修改"
  159. :visible.sync="resetVisible"
  160. width="500px"
  161. destroy-on-close>
  162. <el-form :model="resetForm"
  163. class="resetForm"
  164. ref="resetForm">
  165. <el-form-item label="所属分部"
  166. :rules="[{ required: true, message: '所属分部', trigger: 'blur' }]"
  167. prop="organId"
  168. :label-width="formLabelWidth">
  169. <el-select placeholder="请选择分部"
  170. v-model="resetForm.organId"
  171. clearable
  172. disabled>
  173. <el-option v-for="(item, index) in organList"
  174. :label="item.name"
  175. :value="item.id"
  176. :key="index"></el-option>
  177. </el-select>
  178. </el-form-item>
  179. <el-form-item label="课程类型"
  180. :rules="[
  181. { required: true, message: '请选择课程类型', trigger: 'blur' },
  182. ]"
  183. prop="courseType"
  184. :label-width="formLabelWidth">
  185. <el-select v-model.trim="resetForm.courseType"
  186. filterable
  187. placeholder="请选择课程类型"
  188. clearable
  189. disabled>
  190. <el-option v-for="item in musicCourseType"
  191. :key="item.value"
  192. :label="item.label"
  193. :value="item.value">
  194. </el-option>
  195. </el-select>
  196. </el-form-item>
  197. <el-form-item v-if="actvieRow"
  198. :label="`${actvieRow.chargeType.name}模式`"
  199. :label-width="formLabelWidth"
  200. :rules="[
  201. {
  202. required: true,
  203. message: '请输入每分钟课程费用',
  204. trigger: 'blur',
  205. },
  206. ]"
  207. prop="unitPrice">
  208. <el-input type="number"
  209. min="0"
  210. step="0.00000001"
  211. v-model="resetForm.unitPrice">
  212. <template slot="append">每分钟费用(元)</template>
  213. </el-input>
  214. </el-form-item>
  215. </el-form>
  216. <div slot="footer">
  217. <el-button @click="resetVisible = false">取 消</el-button>
  218. <el-button type="primary"
  219. @click="resetSubmit">确 定</el-button>
  220. </div>
  221. </el-dialog>
  222. </div>
  223. </template>
  224. <script>
  225. import pagination from "@/components/Pagination/index";
  226. import { getEmployeeOrgan } from "@/api/buildTeam";
  227. import {
  228. chargeTypeList,
  229. getOrganizationCourseUnitPriceSettings,
  230. addOrganizationCourseUnitPrice,
  231. resetOrganizationCourseUnitPrice,
  232. deleteOrganizationCourseUnitPrice,
  233. } from "@/api/specialSetting";
  234. import createDiscount from "./modals/create-discount";
  235. import { musicCourseType } from "@/utils/searchArray";
  236. export default {
  237. name: "typesManager",
  238. components: { pagination, createDiscount },
  239. data () {
  240. return {
  241. musicCourseType,
  242. newVisiable: false,
  243. resetVisible: false,
  244. tableList: [],
  245. dataList: [],
  246. organList: [],
  247. searchForm: {
  248. organId: null,
  249. courseScheduleType: null,
  250. },
  251. createForm: {
  252. organId: null,
  253. courseType: null,
  254. unitPriceJson: {},
  255. },
  256. resetForm: {
  257. unitPrice: null,
  258. courseType: null,
  259. id: null,
  260. organId: null,
  261. },
  262. pageInfo: {
  263. // 分页规则
  264. limit: 10, // 限制显示条数
  265. page: 1, // 当前页
  266. total: 0, // 总条数
  267. page_size: [10, 20, 40, 50], // 选择限制显示条数
  268. },
  269. formLabelWidth: "120px",
  270. actvieRow: null,
  271. };
  272. },
  273. mounted () {
  274. chargeTypeList({
  275. rows: 99999,
  276. page: 1,
  277. }).then((res) => {
  278. if (res.code == 200) {
  279. this.dataList = res.data.rows;
  280. this.dataList.forEach((item) => {
  281. this.$set(this.createForm.unitPriceJson, item.id, null);
  282. });
  283. console.log(this.createForm);
  284. }
  285. });
  286. getEmployeeOrgan().then((res) => {
  287. if (res.code == 200) {
  288. this.organList = res.data;
  289. }
  290. });
  291. this.getList();
  292. },
  293. methods: {
  294. search () {
  295. this.pageInfo.page = 1;
  296. this.getList();
  297. },
  298. onReSet () {
  299. this.searchForm = {
  300. organId: null,
  301. courseScheduleType: null,
  302. };
  303. this.search();
  304. },
  305. async onTypesDel (row) {
  306. try {
  307. await this.$confirm("是否删除此条数据?", "提示", {
  308. confirmButtonText: "确定",
  309. cancelButtonText: "取消",
  310. type: "warning",
  311. });
  312. delChargeTypeSubjectMapper({ id: row.id }).then((res) => {
  313. this.messageTips("删除", res);
  314. });
  315. } catch (error) { }
  316. },
  317. getList () {
  318. getOrganizationCourseUnitPriceSettings({
  319. rows: this.pageInfo.limit,
  320. page: this.pageInfo.page,
  321. organId: this.searchForm.organId,
  322. courseScheduleType: this.searchForm.courseScheduleType,
  323. }).then((res) => {
  324. let result = res.data;
  325. this.tableList = result.rows;
  326. this.pageInfo.total = result.total;
  327. // }
  328. });
  329. },
  330. submitInfo () {
  331. this.$refs.ruleForm.validate(async (valid) => {
  332. const data = [];
  333. for (const key in this.createForm.unitPriceJson) {
  334. if (this.createForm.unitPriceJson.hasOwnProperty(key)) {
  335. const item = this.createForm.unitPriceJson[key];
  336. data.push({
  337. chargeTypeId: key,
  338. courseType: this.createForm.courseType,
  339. organId: this.createForm.organId,
  340. unitPrice: item,
  341. });
  342. }
  343. }
  344. if (valid) {
  345. try {
  346. await addOrganizationCourseUnitPrice(data);
  347. this.$message.success("创建成功");
  348. this.getList();
  349. this.newVisiable = false;
  350. this.createForm = {
  351. organId: null,
  352. courseType: null,
  353. unitPriceJson: {},
  354. };
  355. this.dataList.forEach((item) => {
  356. this.$set(this.createForm.unitPriceJson, item.id, null);
  357. });
  358. } catch (error) { }
  359. }
  360. });
  361. },
  362. openTypes (row) {
  363. this.actvieRow = row;
  364. this.resetForm = {
  365. chargeTypeId: row.chargeTypeId,
  366. unitPrice: row.unitPrice,
  367. courseType: row.courseType,
  368. id: row.id,
  369. organId: row.organId,
  370. };
  371. this.resetVisible = true;
  372. },
  373. resetSubmit () {
  374. // resetOrganizationCourseUnitPrice
  375. this.$refs.resetForm.validate(async (valid) => {
  376. if (valid) {
  377. try {
  378. await resetOrganizationCourseUnitPrice(this.resetForm);
  379. this.$message.success("修改成功");
  380. this.getList();
  381. this.resetVisible = false;
  382. this.resetForm = {
  383. unitPrice: null,
  384. courseType: null,
  385. id: null,
  386. organId: null,
  387. };
  388. } catch (error) { }
  389. }
  390. });
  391. },
  392. },
  393. };
  394. </script>
  395. <style lang="scss" scoped>
  396. .el-button--primary {
  397. background: #14928a;
  398. border-color: #14928a;
  399. color: #fff;
  400. &:hover,
  401. &:active,
  402. &:focus {
  403. background: #14928a;
  404. border-color: #14928a;
  405. color: #fff;
  406. }
  407. }
  408. /deep/.el-date-editor.el-input {
  409. width: 100% !important;
  410. }
  411. .el-select {
  412. width: 100% !important;
  413. }
  414. .createForm {
  415. /deep/.el-input {
  416. width: 340px !important;
  417. }
  418. }
  419. </style>