cloudTeacherFee.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class="m-container">
  3. <!-- <h2>收费类型设置</h2> -->
  4. <div class="m-core">
  5. <el-button
  6. class="newBand"
  7. type="primary"
  8. v-if="$helpers.permission('organizationCloudTeacherFee/add')"
  9. @click="openTypes('create')"
  10. >添加</el-button
  11. >
  12. <save-form
  13. :inline="true"
  14. @submit="onSearch"
  15. :saveKey="'cloudTeacherFee'"
  16. :model="searchForm"
  17. >
  18. <el-form-item>
  19. <el-select
  20. placeholder="请选择分部"
  21. v-model="searchForm.organId"
  22. clearable
  23. >
  24. <el-option
  25. v-for="(item, index) in selects.branchs"
  26. :key="index"
  27. :label="item.name"
  28. :value="item.id"
  29. ></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-form-item>
  35. </save-form>
  36. <!-- 列表 -->
  37. <div class="tableWrap">
  38. <el-table
  39. :data="tableList"
  40. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  41. >
  42. <el-table-column align="center" prop="organName" label="分部">
  43. </el-table-column>
  44. <el-table-column align="center" prop="price" label="云练习价格(元)">
  45. <template slot-scope="scope">
  46. {{ scope.row.price | moneyFormat }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" prop="price">
  50. <template #header>
  51. 云练习<sup>+</sup>价格(元)
  52. </template>
  53. <template slot-scope="scope">
  54. {{ scope.row.plusPrice | moneyFormat }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. align="center"
  59. v-if="$helpers.permission('organizationCloudTeacherFee/update')"
  60. label="操作"
  61. >
  62. <template slot-scope="scope">
  63. <el-button @click="openTypes('update', scope.row)" type="text"
  64. >修改</el-button
  65. >
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <pagination
  70. saveKey="cloudTeacherFee"
  71. sync
  72. :total.sync="pageInfo.total"
  73. :page.sync="pageInfo.page"
  74. :limit.sync="pageInfo.limit"
  75. :page-sizes="pageInfo.page_size"
  76. @pagination="getList"
  77. />
  78. </div>
  79. </div>
  80. <el-dialog
  81. :title="formTitle[formActionTitle]"
  82. :visible.sync="typeStatus"
  83. @close="onFormClose('ruleForm')"
  84. width="500px"
  85. >
  86. <el-form :model="form" :rules="rules" ref="ruleForm">
  87. <el-form-item label="分部" prop="organId" :label-width="formLabelWidth">
  88. <el-select
  89. placeholder="请选择分部"
  90. v-model="form.organId"
  91. :disabled="formActionTitle == 'update'"
  92. >
  93. <el-option
  94. v-for="(item, index) in selects.branchs"
  95. :key="index"
  96. :label="item.name"
  97. :value="item.id"
  98. ></el-option>
  99. </el-select>
  100. </el-form-item>
  101. <el-form-item
  102. label="云练习价格"
  103. prop="price"
  104. :label-width="formLabelWidth"
  105. >
  106. <el-input
  107. v-model.number="form.price"
  108. placeholder="请输入价格"
  109. type="number"
  110. autocomplete="off"
  111. ></el-input>
  112. </el-form-item>
  113. <el-form-item prop="plusPrice" :label-width="formLabelWidth">
  114. <template #label>
  115. 云练习<sup>+</sup>价格
  116. </template>
  117. <el-input
  118. v-model.number="form.plusPrice"
  119. placeholder="请输入价格"
  120. type="number"
  121. autocomplete="off"
  122. ></el-input>
  123. </el-form-item>
  124. </el-form>
  125. <span slot="footer" class="dialog-footer">
  126. <el-button @click="typeStatus = false">取 消</el-button>
  127. <el-button type="primary" @click="onTypesSubmit('ruleForm')"
  128. >确 定</el-button
  129. >
  130. </span>
  131. </el-dialog>
  132. </div>
  133. </template>
  134. <script>
  135. import pagination from "@/components/Pagination/index";
  136. import {
  137. organizationCloudTeacherFeeQueryPage,
  138. organizationCloudTeacherFeeAdd,
  139. organizationCloudTeacherFeeUpdate
  140. } from "@/api/specialSetting";
  141. export default {
  142. name: "typesManager",
  143. components: { pagination },
  144. data() {
  145. return {
  146. tableList: [],
  147. searchForm: {
  148. organId: null
  149. },
  150. formActionTitle: "create",
  151. formTitle: {
  152. create: "添加分部云练习价格",
  153. update: "修改分部云练习价格"
  154. },
  155. typeStatus: false, // 添加教学点
  156. formLabelWidth: "120px",
  157. form: {
  158. organId: null, //
  159. price: null,
  160. plusPrice: null
  161. },
  162. rules: {
  163. organId: [{ required: true, message: "请选择分部", trigger: "change" }],
  164. price: [{ required: true, message: "请输入价格", trigger: "blur" }],
  165. plusPrice: [{ required: true, message: "请输入价格", trigger: "blur" }]
  166. },
  167. pageInfo: {
  168. // 分页规则
  169. limit: 10, // 限制显示条数
  170. page: 1, // 当前页
  171. total: 0, // 总条数
  172. page_size: [10, 20, 40, 50] // 选择限制显示条数
  173. }
  174. };
  175. },
  176. mounted() {
  177. // 获取分部
  178. this.$store.dispatch("setBranchs");
  179. this.getList();
  180. },
  181. methods: {
  182. onSearch() {
  183. this.pageInfo.page = 1;
  184. this.getList();
  185. },
  186. onTypesSubmit(formName) {
  187. // 添加数据
  188. this.$refs[formName].validate(valid => {
  189. if (valid) {
  190. if (this.formActionTitle == "create") {
  191. if (this.form.id) {
  192. // 判断有没有Id,如果有则删除
  193. delete this.form.id;
  194. }
  195. organizationCloudTeacherFeeAdd(this.form).then(res => {
  196. this.messageTips("添加", res);
  197. });
  198. } else if (this.formActionTitle == "update") {
  199. organizationCloudTeacherFeeUpdate(this.form).then(res => {
  200. this.messageTips("修改", res);
  201. });
  202. }
  203. } else {
  204. return false;
  205. }
  206. });
  207. },
  208. messageTips(title, res) {
  209. if (res.code == 200) {
  210. this.$message.success(title + "成功");
  211. this.typeStatus = false;
  212. this.getList();
  213. } else {
  214. this.$message.error(res.msg);
  215. }
  216. },
  217. async getList() {
  218. try {
  219. let res = await organizationCloudTeacherFeeQueryPage({
  220. ...this.searchForm,
  221. rows: this.pageInfo.limit,
  222. page: this.pageInfo.page
  223. });
  224. let result = res.data;
  225. this.tableList = result.rows;
  226. this.pageInfo.total = result.total;
  227. } catch {
  228. //
  229. }
  230. },
  231. openTypes(type, row) {
  232. this.typeStatus = true;
  233. this.formActionTitle = type;
  234. // 修改的时候赋值
  235. if (type == "update") {
  236. this.$nextTick(() => {
  237. this.form = {
  238. id: row.id,
  239. organId: row.organId,
  240. price: row.price,
  241. plusPrice: row.plusPrice
  242. };
  243. });
  244. }
  245. },
  246. onFormClose(formName) {
  247. // 关闭弹窗重置验证
  248. this.form = {
  249. organId: null, // 训练模块名称
  250. price: null,
  251. plusPrice: null
  252. };
  253. this.$refs[formName].resetFields();
  254. }
  255. }
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. ::v-deep .el-date-editor.el-input {
  260. width: 100% !important;
  261. }
  262. .el-select {
  263. width: 100% !important;
  264. }
  265. </style>