musicCourseFee.vue 13 KB

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