musicCourseFee.vue 14 KB

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