add.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>心理量表后台维护界面</title>
  8. <link rel="stylesheet" href="./css/element-ui.css">
  9. <script src="./js/Vue.js"></script>
  10. <script src="./js/element-ui.js"></script>
  11. <script src="./js/2.1.4jquery.min.js"></script>
  12. <style>
  13. * {
  14. margin: 0;
  15. padding: 0;
  16. }
  17. body {
  18. /*background: #F2F6FC;*/
  19. }
  20. .sources {
  21. width: 100%;
  22. padding: 24px;
  23. box-sizing: border-box;
  24. border: 1px solid #ebebeb;
  25. border-radius: 3px;
  26. transition: .2s;
  27. margin-bottom: 40px;
  28. }
  29. h2 {
  30. font-size: 24px;
  31. color: #333333;
  32. line-height: 80px;
  33. text-align: center;
  34. }
  35. .wrap {
  36. width: 1280px;
  37. margin: 0 auto;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div id="app">
  43. <div class="wrap">
  44. <h2>心理量表后台维护界面</h2>
  45. <div class="sources">
  46. <el-row>
  47. <el-col :span="14">
  48. <el-form style="width: 100%" ref="form" :model="form" label-width="140px">
  49. <el-form-item label="量表导入模板下载">
  50. <el-button type="primary" @click="download(1)">下载</el-button>
  51. </el-form-item>
  52. <el-form-item label="文件">
  53. <el-input @change="getFile" type="file" v-model="form.file"></el-input>
  54. </el-form-item>
  55. <el-form-item label="量表名称">
  56. <el-input v-model="form.scaleName"></el-input>
  57. </el-form-item>
  58. <el-form-item label="量表英文名称">
  59. <el-input v-model="form.eName"></el-input>
  60. </el-form-item>
  61. <el-form-item label="量表指导语">
  62. <el-input type="textarea" v-model="form.scaleDesc"></el-input>
  63. </el-form-item>
  64. <el-form-item label="计分原则">
  65. <el-input type="textarea" v-model="form.scoringPrinciple"></el-input>
  66. </el-form-item>
  67. <el-form-item label="量表录入人">
  68. <el-input v-model="form.uploader"></el-input>
  69. </el-form-item>
  70. <el-form-item label="量表分类">
  71. <el-select v-model="form.scaleCate" multiple placeholder="请选择">
  72. <el-option v-for="item in categorys" :key="item.sequence" :label="item.name"
  73. :value="item.ename">
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="适用人群">
  78. <el-select v-model="people" multiple placeholder="请选择">
  79. <el-option v-for="item in men" :key="item.sequence" :label="item.label"
  80. :value="item.value" :disabled="item.value != 0 && !disabled">
  81. </el-option>
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item label="量表权限">
  85. <el-select v-model="form.currentLimit" placeholder="量表权限">
  86. <el-option v-for="item in limit" :label="item.label" :value="item.value">
  87. </el-option>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item>
  91. <el-button :disabled="isLoading" type="primary" @click="onSubmit">提交</el-button>
  92. <el-button>清空</el-button>
  93. </el-form-item>
  94. </el-form>
  95. </el-col>
  96. </el-row>
  97. </div>
  98. </div>
  99. </div>
  100. </body>
  101. <script>
  102. var app = new Vue({
  103. el: '#app',
  104. data: {
  105. currentPage: 1,
  106. form: {
  107. eName: ''
  108. },
  109. people: [],
  110. tableData: [],
  111. total: 0,
  112. file: {},
  113. isLoading: false,
  114. searchName: '',
  115. categorys: [],
  116. scaleCate: [],
  117. men: [{ value: '0', label: '全部' }, { value: '1', label: '儿童' }, { value: '2', label: '小学生' }, { value: '3', label: '中学及以上' }, { value: '4', label: '军警' }
  118. , { value: '5', label: '老年人' }, { value: '6', label: '精神病患者' }, { value: '7', label: '家长' }, { value: '8', label: '护士长' }, { value: '9', label: '单身人士' }
  119. , { value: '10', label: '职工' }, { value: '11', label: '心理疾病患者' }, { value: '12', label: '身体疾病患者' }, { value: '13', label: '青少年' }, { value: '14', label: '成年人' }
  120. , { value: '15', label: '教师' }, { value: '16', label: '孕妇' }, { value: '17', label: '已婚人士' }, { value: '18', label: '女性' }, { value: '19', label: '男性' }
  121. , { value: '20', label: '运动员' }, { value: '21', label: '司机' }, { value: '22', label: '医务人员' }, { value: '23', label: '教练' }, { value: '24', label: '糖尿病患者' }
  122. , { value: '25', label: '患者家属' }],
  123. limit: [{ value: 'public', label: '公开' }, { value: 'private', label: '私密' }],
  124. currentLimit: "",
  125. dialogFormVisible: false,
  126. editInfo: {
  127. id: "",
  128. type: [],
  129. scaleLimit: "",
  130. flag: ""
  131. },
  132. ePeople: []
  133. },
  134. computed: {
  135. disabled() {
  136. return this.people.indexOf('0') == -1
  137. },
  138. eDisabled() {
  139. return this.ePeople.indexOf('0') == -1
  140. }
  141. },
  142. created: function () {
  143. this.loadData(1, 10);
  144. this.loadCategory();
  145. },
  146. methods: {
  147. changeCategory: function (ename) {
  148. let name = "";
  149. this.categorys.forEach((item) => {
  150. if (item.ename == ename) {
  151. name = item.name;
  152. }
  153. })
  154. return name
  155. },
  156. loadCategory: function () {
  157. vm = this;
  158. $.ajax({
  159. type: "GET",
  160. url: "http://cognitive.wistcm.com:8080/category/loadCategory",
  161. success: function (data) {
  162. vm.categorys = data.data;
  163. }
  164. });
  165. },
  166. loadData: function (n, s) {
  167. var searchURL = "http://cognitive.wistcm.com:8080/subjectInfo?pageNum=" + n + "&pageSize=" + s;
  168. if (this.searchName != '') {
  169. searchURL = searchURL + "&searchName=" + this.searchName;
  170. }
  171. console.log("searchUrl-----" + searchURL);
  172. $.ajax({
  173. type: "GET",
  174. url: searchURL,
  175. success: function (data) {
  176. app.tableData = data.data.data;
  177. app.total = data.data.allNum;
  178. }
  179. });
  180. },
  181. getFile: function () {
  182. this.file = event.target.files[0];
  183. },
  184. onSubmit: function () {
  185. if (this.isLoading) {
  186. this.$message.error('请勿重复提交');
  187. return;
  188. }
  189. if (!this.form.file) {
  190. this.$message.error('请上传文件');
  191. return;
  192. }
  193. if (!this.form.scaleName) {
  194. this.$message.error('量表名称不能为空');
  195. return;
  196. }
  197. if (!this.form.scaleDesc) {
  198. this.$message.error('量表指导语不能为空');
  199. return;
  200. }
  201. if (!this.form.uploader) {
  202. this.$message.error('量表录入人不能为空');
  203. return;
  204. }
  205. if (!this.form.scoringPrinciple) {
  206. this.$message.error('量表录入人不能为空');
  207. return;
  208. }
  209. var formdata = new FormData();
  210. formdata.append("file", this.file);
  211. formdata.append("scaleName", this.form.scaleName);
  212. formdata.append("eName", this.form.eName);
  213. formdata.append("scaleDesc", this.form.scaleDesc);
  214. formdata.append("uploader", this.form.uploader);
  215. formdata.append("scoringPrinciple", this.form.scoringPrinciple);
  216. formdata.append("scaleCate", this.form.scaleCate);
  217. formdata.append("people", this.people)
  218. formdata.append("currentLimit", this.form.currentLimit);
  219. this.isLoading = true;
  220. $.ajax({
  221. type: "POST",
  222. url: "http://cognitive.wistcm.com:8080/subjectInfoUpload/importTest",
  223. contentType: false,
  224. processData: false,
  225. data: formdata
  226. }).then(data => {
  227. this.isLoading = false;
  228. if (data.code == 200) {
  229. this.$message.success("提交成功");
  230. this.people = [];
  231. } else {
  232. this.$message.error(data.msg);
  233. }
  234. this.clearForm();
  235. this.loadData(1, 10);
  236. })
  237. },
  238. currentChange(i) {
  239. this.currentPage = i;
  240. this.loadData(i, 10);
  241. },
  242. download: function (i, name) {
  243. if (i == 1) {
  244. window.open('http://cognitive.wistcm.com:8080/file/download/model', '_blank');
  245. } else {
  246. window.open("http://cognitive.wistcm.com:8080/file/download/scale?file_name=" + name, '_blank');
  247. }
  248. },
  249. clearForm: function () {
  250. this.form = {};
  251. this.file = {};
  252. },
  253. // 修改
  254. edit(info) {
  255. this.ePeople = [];
  256. this.editInfo.type = [];
  257. if (info.category != null) {
  258. info.category.forEach(item => {
  259. this.editInfo.type.push(item.ename)
  260. })
  261. }
  262. this.editInfo.scaleLimit = info.scaleLimit;
  263. this.editInfo.id = info.id;
  264. this.editInfo.flag = info.flag;
  265. if (info.people) {
  266. this.ePeople = info.people.split(',');
  267. }
  268. this.dialogFormVisible = true;
  269. },
  270. updateScaleInfo() {
  271. let vm = this
  272. vm.editInfo.people = this.ePeople;
  273. $.ajax({
  274. type: "POST",
  275. url: "http://cognitive.wistcm.com:8080/subjectInfoUpload/update",
  276. contentType: 'application/json;charset=utf-8',
  277. data: JSON.stringify(vm.editInfo),
  278. }).then(data => {
  279. this.isLoading = false;
  280. this.$message.success("提交成功");
  281. this.ePeople = [];
  282. this.clearForm();
  283. this.loadData(vm.currentPage, 10);
  284. }).catch(res => {
  285. this.$message.error("提交失败");
  286. })
  287. }
  288. }
  289. })
  290. </script>
  291. </html>