index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div>
  3. <div class="mt20">
  4. <el-button type="primary" @click="addData">添加</el-button>
  5. <el-button
  6. type="danger"
  7. @click="delData"
  8. :disabled="multipleSelection.length == 0"
  9. >删除</el-button
  10. >
  11. </div>
  12. <el-table
  13. :data="tableData"
  14. tooltip-effect="dark"
  15. v-loading="loading"
  16. ref="multipleTable"
  17. @selection-change="handleSelectionChange"
  18. class="mt20"
  19. style="width: 100%"
  20. >
  21. <el-table-column type="selection" align="center" width="55">
  22. </el-table-column>
  23. <el-table-column label="检查项目" prop="xdww_name"> </el-table-column>
  24. <el-table-column label="操作">
  25. <template slot-scope="scope">
  26. <el-button type="text" @click="editData(scope.row)">编辑 </el-button>
  27. <el-button type="text" @click="pfxData(scope.row.xdww_id)"
  28. >评分项
  29. </el-button>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. <footer
  34. class="flex-item-none"
  35. style="display: flex; justify-content: flex-end; margin-top: 30px"
  36. >
  37. <el-pagination
  38. background
  39. layout="total,prev, pager, next"
  40. :page-size="limit"
  41. :total="total"
  42. :current-page.sync="cur_page"
  43. @current-change="handleCurrentChange"
  44. ></el-pagination>
  45. </footer>
  46. <el-dialog
  47. :title="title"
  48. :visible.sync="dialogFormVisible"
  49. append-to-body
  50. width="580px"
  51. >
  52. <el-form
  53. :inline="true"
  54. :model="dialogForm"
  55. ref="dialogForm"
  56. :rules="rules"
  57. label-width="120px"
  58. >
  59. <h4 class="mb20 ml30 font-size-14" style="color: #265cd4">
  60. 每个班级总分为100分(卫生50分+常规50分)
  61. </h4>
  62. <el-form-item class="mr75" label="检查项目名称" prop="wdmc">
  63. <el-input
  64. placeholder="请输入检查项目名称"
  65. v-model="dialogForm.wdmc"
  66. ></el-input>
  67. </el-form-item>
  68. </el-form>
  69. <div slot="footer" class="text-center">
  70. <el-button @click="formCancel">取 消</el-button>
  71. <el-button :disabled="isButton" type="primary" @click="formSubmit('dialogForm')"
  72. >确 定</el-button
  73. >
  74. </div>
  75. </el-dialog>
  76. </div>
  77. </template>
  78. <script>
  79. import { wdsz_list, wdsz_add, wdsz_edit, wdsz_del } from "./api";
  80. export default {
  81. name: "index",
  82. data() {
  83. return {
  84. limit: 10,
  85. total: 12,
  86. cur_page: 1,
  87. keyword: "",
  88. tableData: [],
  89. title: "",
  90. id: "",
  91. loading: false,
  92. isEdit: false,
  93. dialogFormVisible: false,
  94. dialogForm: {
  95. wdmc: "",
  96. },
  97. rules: {
  98. wdmc: [{ required: true, message: "请输入维度名称", trigger: "blur" }],
  99. },
  100. multipleSelection: [],
  101. isButton: false,
  102. };
  103. },
  104. methods: {
  105. handleCurrentChange(val) {
  106. this.cur_page = val;
  107. this.getListData();
  108. },
  109. getListData() {
  110. this.loading = true;
  111. let data = {
  112. page: this.cur_page,
  113. limit: this.limit,
  114. keyword: this.keyword,
  115. xdbs_jclx: "1",
  116. };
  117. wdsz_list(data).then((res) => {
  118. this.loading = false;
  119. this.tableData = res.data.page_data;
  120. this.cur_page = Number(res.data.page_now);
  121. this.total = Number(res.data.total_rows);
  122. });
  123. },
  124. addData() {
  125. this.isButton = false;
  126. this.title = "添加";
  127. this.dialogForm = {
  128. wdmc: "",
  129. };
  130. this.isEdit = false;
  131. this.dialogFormVisible = true;
  132. },
  133. editData(item) {
  134. this.isButton = false;
  135. this.title = "编辑信息";
  136. this.isEdit = true;
  137. this.dialogFormVisible = true;
  138. this.id = item.xdww_id;
  139. this.dialogForm.wdmc = item.xdww_name;
  140. },
  141. formSubmit(formName) {
  142. this.$refs[formName].validate((valid) => {
  143. if (valid) {
  144. this.isButton = true;
  145. let data = {
  146. xdww_name: this.dialogForm.wdmc,
  147. xdbs_jclx: "1",
  148. };
  149. if (!this.isEdit) {
  150. wdsz_add(data).then((res) => {
  151. if (res.code == 1) {
  152. this.$message({
  153. message: "信息添加成功!",
  154. type: "success",
  155. });
  156. this.isButton = true;
  157. this.dialogFormVisible = false;
  158. this.getListData();
  159. } else {
  160. this.$message({
  161. message: res.msg,
  162. type: "error",
  163. });
  164. }
  165. });
  166. } else {
  167. data.xdww_id = this.id;
  168. wdsz_edit(data).then((res) => {
  169. if (res.code == 1) {
  170. this.$message({
  171. message: "信息编辑成功!",
  172. type: "success",
  173. });
  174. this.dialogFormVisible = false;
  175. this.getListData();
  176. } else {
  177. this.$message({
  178. message: res.msg,
  179. type: "error",
  180. });
  181. }
  182. });
  183. }
  184. }
  185. else {
  186. this.isButton = false
  187. }
  188. });
  189. },
  190. formCancel() {
  191. this.dialogFormVisible = false;
  192. },
  193. delData() {
  194. this.$confirm("确认删除这些信息?", "提示", {
  195. confirmButtonText: "确定",
  196. cancelButtonText: "取消",
  197. type: "warning",
  198. })
  199. .then(() => {
  200. let data = {
  201. xdww_id: this.multipleSelection,
  202. };
  203. wdsz_del(data).then((res) => {
  204. if (res.code == 1) {
  205. this.$message({
  206. message: "信息删除成功!",
  207. type: "success",
  208. });
  209. this.getListData();
  210. } else {
  211. this.$message({
  212. message: res.msg,
  213. type: "error",
  214. });
  215. }
  216. });
  217. })
  218. .catch(() => {});
  219. },
  220. handleSelectionChange(val) {
  221. this.multipleSelection = [];
  222. for (let i in val) {
  223. this.multipleSelection.push(val[i].xdww_id);
  224. }
  225. },
  226. pfxData(id) {
  227. this.$router.push({ name: "wypj_wdsz_wdpfx", params: { id: id } });
  228. },
  229. },
  230. mounted() {
  231. this.getListData();
  232. },
  233. };
  234. </script>
  235. <style scoped></style>;