index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div id="videoConfig">
  3. <div class="boxWs">
  4. <header class="hedsa">视频播放</header>
  5. <div class="bigBoxs">
  6. <el-form label-width="100px" class="demo-ruleForm">
  7. <el-form-item
  8. v-for="(item, index) in listitem"
  9. :key="index"
  10. :label="item.configName"
  11. >
  12. <el-radio-group v-model="item.configValue">
  13. <el-radio label="1">开启</el-radio>
  14. <el-radio label="0">禁止</el-radio>
  15. </el-radio-group>
  16. </el-form-item>
  17. </el-form>
  18. <el-button @click="submit" v-hasPermi="['system:config:edit']">保存</el-button>
  19. </div>
  20. </div>
  21. <div class="boxWs">
  22. <header class="hedsa">视频-课程节-拍照</header>
  23. <div class="bigBoxs">
  24. <el-form label-width="100px" class="demo-ruleForm">
  25. <el-form-item :label="videoActive.configName">
  26. <el-radio-group v-model="videoActive.configValue">
  27. <el-radio label="1" @change="videoPhotoJG.configValue.push(0)"
  28. >是</el-radio
  29. >
  30. <el-radio label="0" @change="videoPhotoJG.configValue = []"
  31. >否</el-radio
  32. >
  33. </el-radio-group>
  34. <el-button
  35. style="margin-left: 12px"
  36. size="mini"
  37. v-if="videoActive.configValue === '1'"
  38. @click="videoPhotoJG.configValue.push(0)"
  39. >添加</el-button
  40. >
  41. </el-form-item>
  42. <template v-if="videoActive.configValue == 1">
  43. <el-form-item
  44. v-for="(item, index) in videoPhotoJG.configValue"
  45. :key="index"
  46. label="播放至"
  47. >
  48. <el-input-number
  49. :controls="false"
  50. v-model="videoPhotoJG.configValue[index]"
  51. controls-position="right"
  52. :min="0"
  53. ></el-input-number
  54. >分钟
  55. <el-button type="warning" size="mini" @click="del(index)"
  56. >删除</el-button
  57. >
  58. </el-form-item>
  59. </template>
  60. </el-form>
  61. <el-button @click="submitVideo" >保存</el-button>
  62. </div>
  63. </div>
  64. <div class="boxWs">
  65. <header class="hedsa">视频-课程章节-关联题卷-拍照</header>
  66. <div class="bigBoxs">
  67. <el-form label-width="100px" class="demo-ruleForm">
  68. <el-form-item :label="bankActive.configName">
  69. <el-radio-group v-model="bankActive.configValue">
  70. <el-radio label="1"
  71. >是</el-radio
  72. >
  73. <el-radio label="0" @change="bankPhotoJG.configValue = []"
  74. >否</el-radio
  75. >
  76. </el-radio-group>
  77. <!-- <el-button
  78. style="margin-left: 12px"
  79. size="mini"
  80. v-if="bankActive.configValue === '1'"
  81. @click="bankPhotoJG.configValue.push(0)"
  82. >添加</el-button
  83. > -->
  84. </el-form-item>
  85. <template v-if="bankActive.configValue == 1">
  86. <el-form-item
  87. v-for="(item, index) in bankPhotoJG.configValue"
  88. :key="index"
  89. label="做题至第"
  90. >
  91. <!-- <num-input
  92. :value="item"
  93. @changevalues="changeValues(index, $event)"
  94. message="请输入数值"
  95. min="1"
  96. /> -->
  97. <el-input-number
  98. :controls="false"
  99. v-model="bankPhotoJG.configValue[index]"
  100. controls-position="right"
  101. :min="0"
  102. :precision="0"
  103. ></el-input-number>
  104. <el-button type="warning" size="mini" @click="delbank(index)"
  105. >删除</el-button
  106. >
  107. </el-form-item>
  108. </template>
  109. </el-form>
  110. <el-button @click="submitBank">保存</el-button>
  111. </div>
  112. </div>
  113. <div style="clear: both"></div>
  114. </div>
  115. </template>
  116. <script>
  117. import numInput from "@/components/numInput";
  118. import {
  119. listConfig,
  120. getConfig,
  121. delConfig,
  122. addConfig,
  123. updateConfig,
  124. exportConfig,
  125. refreshCache,
  126. } from "@/api/system/config";
  127. export default {
  128. components: { numInput },
  129. data() {
  130. return {
  131. listitem: [],
  132. videoActive: {},
  133. videoPhotoJG: {},
  134. bankActive: {},
  135. bankPhotoJG: {},
  136. };
  137. },
  138. mounted() {
  139. this.getConfig();
  140. },
  141. methods: {
  142. changeValues(int, value) {
  143. if (value) {
  144. var ast = this.bankPhotoJG.configValue.some((item) => {
  145. return item == value;
  146. });
  147. if (ast) {
  148. this.$message.error("存在相同值,请重新输入");
  149. this.$set(this.bankPhotoJG.configValue, int, "");
  150. } else {
  151. this.$set(this.bankPhotoJG.configValue, int, value);
  152. }
  153. }else{
  154. this.$set(this.bankPhotoJG.configValue, int, "");
  155. }
  156. },
  157. del(index) {
  158. this.videoPhotoJG.configValue.splice(index, 1);
  159. },
  160. delbank(index) {
  161. this.bankPhotoJG.configValue.splice(index, 1);
  162. },
  163. getConfig() {
  164. listConfig().then((res) => {
  165. var listitems = [];
  166. res.rows.map((item) => {
  167. if (
  168. item.configKey == "sys.play.autoPlay" ||
  169. item.configKey == "sys.play.drag" ||
  170. item.configKey == "sys.play.speed"
  171. ) {
  172. listitems.push(item);
  173. }
  174. if (item.configKey == "sys.course.photograph") {
  175. this.videoActive = item;
  176. }
  177. if (item.configKey == "sys.paper.photograph") {
  178. this.bankActive = item;
  179. }
  180. if (item.configKey == "sys.course.intervalTime") {
  181. if (item.configValue) {
  182. item.configValue = item.configValue.split(",");
  183. } else {
  184. item.configValue = [];
  185. }
  186. this.videoPhotoJG = item;
  187. }
  188. if (item.configKey == "sys.paper.intervalNumber") {
  189. if (item.configValue) {
  190. item.configValue = item.configValue.split(",");
  191. } else {
  192. item.configValue = [];
  193. }
  194. this.bankPhotoJG = item;
  195. }
  196. });
  197. this.listitem = listitems;
  198. });
  199. },
  200. async submit() {
  201. for (let i = 0; i < this.listitem.length; i++) {
  202. await updateConfig(this.listitem[i]);
  203. }
  204. this.$modal.msgSuccess("修改成功");
  205. },
  206. async submitVideo() {
  207. // if (this.videoActive.configValue == 1) {
  208. if (
  209. this.videoActive.configValue == 1 &&
  210. !this.videoPhotoJG.configValue.length
  211. ) {
  212. this.$modal.msgError("参数键值不能为空");
  213. return;
  214. } else {
  215. var arr = {};
  216. for (let k in this.videoPhotoJG) {
  217. if (k == "configValue") {
  218. var arrs = this.videoPhotoJG[k];
  219. if (new Set(arrs).size != arrs.length) {
  220. this.$message.warning("不允许存在重复值");
  221. return;
  222. }
  223. arr[k] = this.videoPhotoJG[k].toString();
  224. } else {
  225. arr[k] = this.videoPhotoJG[k];
  226. }
  227. }
  228. await updateConfig(this.videoActive);
  229. await updateConfig(arr);
  230. this.$modal.msgSuccess("修改成功");
  231. this.getConfig();
  232. }
  233. // } else {
  234. // await updateConfig(this.videoActive);
  235. // this.$modal.msgSuccess("修改成功");
  236. // this.getConfig();
  237. // }
  238. },
  239. async submitBank() {
  240. // if (this.bankActive.configValue == 1) {
  241. // if (this.bankActive.configValue == 1 && !this.bankPhotoJG.configValue.length) {
  242. // this.$modal.msgError("参数键值不能为空");
  243. // return;
  244. // } else {
  245. // var arr = {};
  246. // for (let k in this.bankPhotoJG) {
  247. // if (k == "configValue") {
  248. // var arrs = this.bankPhotoJG[k];
  249. // if (new Set(arrs).size != arrs.length) {
  250. // this.$message.warning("不允许存在重复值");
  251. // return;
  252. // }
  253. // arr[k] = this.bankPhotoJG[k].toString();
  254. // } else {
  255. // arr[k] = this.bankPhotoJG[k];
  256. // }
  257. // }
  258. await updateConfig(this.bankActive);
  259. // await updateConfig(arr);
  260. this.$modal.msgSuccess("修改成功");
  261. this.getConfig();
  262. // }
  263. // } else {
  264. // await updateConfig(this.bankActive);
  265. // this.$modal.msgSuccess("修改成功");
  266. // this.getConfig();
  267. // }
  268. },
  269. },
  270. };
  271. </script>
  272. <style lang="less" scoped>
  273. .boxWs {
  274. margin: 0px 20px 20px 0px;
  275. float: left;
  276. width: 450px;
  277. height: 400px;
  278. border-radius: 8px;
  279. overflow: hidden;
  280. border: 1px solid #eee;
  281. .hedsa {
  282. background-color: #999;
  283. padding: 6px;
  284. }
  285. .bigBoxs {
  286. height: 367px;
  287. padding: 14px;
  288. overflow-y: auto;
  289. }
  290. }
  291. </style>