musicCourseFee.vue 14 KB

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