gradientSet.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div class='m-container'>
  3. <!-- <h2>参数设置</h2> -->
  4. <div class="m-core">
  5. <!-- 列表 -->
  6. <el-tabs tab-position="left">
  7. <el-tab-pane label="声部课">
  8. <el-form :model="singleForm"
  9. label-width="100px"
  10. class="demo-dynamic">
  11. <el-form-item style="margin-bottom: 0;">
  12. <span class="min">最小值</span>
  13. <span class="max">最大值</span>
  14. </el-form-item>
  15. <div class="moreRule">
  16. <div class="moreRuleIn"
  17. v-for="(domain, index) in singleForm.domains"
  18. :key="domain.key">
  19. <el-form-item :label="'梯度' + (index + 1)">
  20. <el-input type="number"
  21. @mousewheel.native.prevent
  22. :disabled="domain.disabled"
  23. v-model.trim="domain.min"></el-input>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-input type="number"
  27. @mousewheel.native.prevent
  28. :disabled="domain.disabled"
  29. v-model.trim="domain.max"></el-input>
  30. <el-button v-if="index != 0 && !domain.disabled"
  31. @click.prevent="removeDomain(singleForm, domain)">删除</el-button>
  32. </el-form-item>
  33. </div>
  34. <div class="el-form-item__error"
  35. v-if="singleForm.errorText">{{ singleForm.errorText }}</div>
  36. </div>
  37. <el-form-item>
  38. <el-button @click="addDomain(singleForm)">新增梯度</el-button>
  39. <el-button @click="resetForm(singleForm)">重置</el-button>
  40. <el-button type="primary"
  41. @click="submitForm(singleForm)">设置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. </el-tab-pane>
  45. <el-tab-pane label="合奏课">
  46. <el-form :model="mixForm"
  47. label-width="100px"
  48. class="demo-dynamic">
  49. <el-form-item style="margin-bottom: 0;">
  50. <span class="min">最小值</span>
  51. <span class="max">最大值</span>
  52. </el-form-item>
  53. <div class="moreRule">
  54. <div class="moreRuleIn"
  55. v-for="(domain, index) in mixForm.domains"
  56. :key="domain.key">
  57. <el-form-item :label="'梯度' + (index + 1)">
  58. <el-input type="number"
  59. @mousewheel.native.prevent
  60. :disabled="domain.disabled"
  61. v-model.trim="domain.min"></el-input>
  62. </el-form-item>
  63. <el-form-item>
  64. <el-input type="number"
  65. @mousewheel.native.prevent
  66. :disabled="domain.disabled"
  67. v-model.trim="domain.max"></el-input>
  68. <el-button v-if="index != 0 && !domain.disabled"
  69. @click.prevent="removeDomain(mixForm, domain)">删除</el-button>
  70. </el-form-item>
  71. </div>
  72. <div class="el-form-item__error"
  73. v-if="mixForm.errorText">{{ mixForm.errorText }}</div>
  74. </div>
  75. <el-form-item>
  76. <el-button @click="addDomain(mixForm)">新增梯度</el-button>
  77. <el-button @click="resetForm(mixForm)">重置</el-button>
  78. <el-button type="primary"
  79. @click="submitForm(mixForm)">设置</el-button>
  80. </el-form-item>
  81. </el-form>
  82. </el-tab-pane>
  83. <el-tab-pane label="基础技能班">
  84. <el-form :model="highForm"
  85. label-width="100px"
  86. class="demo-dynamic">
  87. <el-form-item style="margin-bottom: 0;">
  88. <span class="min">最小值</span>
  89. <span class="max">最大值</span>
  90. </el-form-item>
  91. <div class="moreRule">
  92. <div class="moreRuleIn"
  93. v-for="(domain, index) in highForm.domains"
  94. :key="domain.key">
  95. <el-form-item :label="'梯度' + (index + 1)">
  96. <el-input type="number"
  97. @mousewheel.native.prevent
  98. :disabled="domain.disabled"
  99. v-model.trim="domain.min"></el-input>
  100. </el-form-item>
  101. <el-form-item>
  102. <el-input type="number"
  103. @mousewheel.native.prevent
  104. :disabled="domain.disabled"
  105. v-model.trim="domain.max"></el-input>
  106. <el-button v-if="index != 0 && !domain.disabled"
  107. @click.prevent="removeDomain(highForm, domain)">删除</el-button>
  108. </el-form-item>
  109. </div>
  110. <div class="el-form-item__error"
  111. v-if="highForm.errorText">{{ highForm.errorText }}</div>
  112. </div>
  113. <el-form-item>
  114. <el-button @click="addDomain(highForm)">新增梯度</el-button>
  115. <el-button @click="resetForm(highForm)">重置</el-button>
  116. <el-button type="primary"
  117. @click="submitForm(highForm)">设置</el-button>
  118. </el-form-item>
  119. </el-form>
  120. </el-tab-pane>
  121. </el-tabs>
  122. </div>
  123. </div>
  124. </template>
  125. <script>
  126. import pagination from '@/components/Pagination/index'
  127. import store from '@/store'
  128. import { sysConfigList, sysConfigUpdate } from '@/api/generalSettings'
  129. export default {
  130. components: { pagination },
  131. name: 'gradientSet',
  132. data () {
  133. return {
  134. organId: null,
  135. singleForm: {
  136. domains: [{
  137. min: null,
  138. max: null,
  139. disabled: false,
  140. key: Date.now()
  141. }],
  142. errorText: null,
  143. },
  144. mixForm: {
  145. domains: [{
  146. min: null,
  147. max: null,
  148. disabled: false,
  149. key: Date.now()
  150. }],
  151. errorText: null,
  152. },
  153. highForm: {
  154. domains: [{
  155. min: null,
  156. max: null,
  157. disabled: false,
  158. key: Date.now()
  159. }],
  160. errorText: null,
  161. },
  162. }
  163. },
  164. mounted () {
  165. this.__init()
  166. },
  167. methods: {
  168. __init () {
  169. sysConfigList({ group: 'settlement_rule' }).then(res => {
  170. if (res.code == 200 && res.data.length > 0) {
  171. res.data.forEach(item => {
  172. let domain = []
  173. if (item.paranValue) {
  174. domain = JSON.parse(item.paranValue)
  175. } else {
  176. domain = [{
  177. min: null,
  178. max: null,
  179. disabled: false,
  180. key: Date.now()
  181. }]
  182. }
  183. let tempArray = {
  184. domains: domain,
  185. errorText: null,
  186. paramName: item.paramName,
  187. id: item.id
  188. }
  189. if (item.paramName == 'sigle_gradient_settlement_rule') {
  190. this.singleForm = tempArray
  191. }
  192. if (item.paramName == "max_gradient_settlement_rule") {
  193. this.mixForm = tempArray
  194. }
  195. if (item.paramName == "high_gradient_settlement_rule") {
  196. this.highForm = tempArray
  197. }
  198. })
  199. }
  200. })
  201. },
  202. submitForm (form) {
  203. this.addDomain(form, true)
  204. if (!form.errorText) {
  205. let params = {
  206. id: form.id,
  207. paranValue: JSON.stringify(form.domains),
  208. paramName: form.paramName
  209. }
  210. sysConfigUpdate(params).then(res => {
  211. if (res.code == 200) {
  212. this.$message.success('设置成功')
  213. }
  214. })
  215. }
  216. },
  217. resetForm (form) {
  218. form.domains = [{
  219. min: null,
  220. max: null,
  221. disabled: false
  222. }]
  223. form.errorText = null
  224. },
  225. removeDomain (form, item) {
  226. var index = form.domains.indexOf(item)
  227. if (index !== -1) {
  228. form.domains.splice(index, 1)
  229. // 取消最后一个数据的禁用状态
  230. form.domains[form.domains.length - 1].disabled = false
  231. form.errorText = null
  232. }
  233. },
  234. addDomain (form, checked) {
  235. // debugger
  236. let domains = form.domains,
  237. singleLength = domains.length,
  238. lastDate = domains[singleLength - 1] // 获取倒数一个对象
  239. if (!lastDate.min) {
  240. form.errorText = '最小值不能为空'
  241. return
  242. }
  243. if (singleLength <= 1 && parseInt(lastDate.min) < 0) {
  244. form.errorText = '最小值不能小于0'
  245. return
  246. } else if (singleLength > 1 && parseInt(lastDate.min) <= parseInt(domains[singleLength - 2].max)) {
  247. form.errorText = '最小值不能小于或等于上一个梯度的最大值'
  248. return
  249. }
  250. if (!parseInt(lastDate.max)) {
  251. form.errorText = '最大值不能为空'
  252. return
  253. } else if (parseInt(lastDate.max) <= parseInt(lastDate.min)) {
  254. form.errorText = '最大值应大于该梯度的最小值'
  255. return
  256. }
  257. form.errorText = null
  258. if (!checked) {
  259. lastDate.disabled = true
  260. domains.push({
  261. min: null,
  262. max: null,
  263. disabled: false,
  264. key: Date.now()
  265. })
  266. }
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="scss" scoped>
  272. /deep/.el-input-group__append {
  273. background: #dcdfe6;
  274. border-color: #dcdfe6;
  275. &:hover,
  276. &:active,
  277. &:focus {
  278. background: #dcdfe6;
  279. border-color: #dcdfe6;
  280. color: #fff;
  281. }
  282. }
  283. .el-button--primary {
  284. background: #14928a;
  285. border-color: #14928a;
  286. color: #fff;
  287. &:hover,
  288. &:active,
  289. &:focus {
  290. background: #14928a;
  291. border-color: #14928a;
  292. color: #fff;
  293. }
  294. }
  295. .el-row {
  296. margin-top: 40px;
  297. }
  298. .el-col {
  299. display: flex;
  300. align-items: center;
  301. margin-bottom: 20px;
  302. justify-content: flex-end;
  303. margin-right: 50%;
  304. }
  305. .min,
  306. .max {
  307. display: inline-block;
  308. width: 180px;
  309. text-align: center;
  310. margin-right: 10px;
  311. }
  312. .el-input-group,
  313. .el-input {
  314. width: 180px;
  315. margin-right: 10px;
  316. }
  317. .moreRule {
  318. position: relative;
  319. .el-form-item__error {
  320. color: #f56c6c;
  321. font-size: 12px;
  322. line-height: 1;
  323. position: absolute;
  324. left: 100px;
  325. top: 100%;
  326. margin-top: -21px;
  327. }
  328. }
  329. .moreRuleIn {
  330. .el-form-item {
  331. display: inline-block;
  332. &:last-child {
  333. /deep/.el-form-item__content {
  334. margin-left: 0 !important;
  335. }
  336. }
  337. }
  338. }
  339. </style>