index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div id="educationType">
  3. <table-list
  4. :tableSets="tableSet"
  5. :tableData="tableData"
  6. :navText="navText"
  7. @addClick="addClick"
  8. :loading="loading"
  9. @editInfo="editInfo"
  10. >
  11. <template slot="btn" slot-scope="props">
  12. <el-button type="text" @click="addClick(props.scope.row, 0)"
  13. >修改</el-button
  14. >
  15. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  16. </template>
  17. </table-list>
  18. <pagination
  19. :total="total"
  20. :pageSize="pageSize"
  21. :currentPage="currentPage"
  22. @handleSizeChange="handleSizeChange"
  23. @handleCurrentChange="handleCurrentChange"
  24. />
  25. <el-dialog
  26. :visible.sync="dialogVisible"
  27. width="560px"
  28. :show-close="false"
  29. :close-on-click-modal="false"
  30. >
  31. <div slot="title" class="hearders">
  32. <div class="leftTitle">
  33. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  34. </div>
  35. <div class="rightBoxs">
  36. <img src="@/assets/images/Close@2x.png" alt="" @click="close" />
  37. </div>
  38. </div>
  39. <div>
  40. <el-form
  41. label-position="right"
  42. label-width="110px"
  43. :model="listData"
  44. :rules="rules"
  45. ref="listData"
  46. >
  47. <el-form-item
  48. v-for="(items, indexs) in listitem"
  49. :key="indexs"
  50. :label="items.label"
  51. :prop="items.prop"
  52. >
  53. <el-radio-group
  54. v-if="items.scope === 'status'"
  55. v-model="listData[items.prop]"
  56. >
  57. <el-radio
  58. v-for="(item, index) in items.options"
  59. :key="index"
  60. :label="item.value"
  61. :disabled="statusPop === 2"
  62. >{{ item.label }}</el-radio
  63. >
  64. </el-radio-group>
  65. <el-input
  66. :disabled="statusPop === 2"
  67. v-else-if="items.scope === 'textarea'"
  68. type="textarea"
  69. v-model="listData[items.prop]"
  70. ></el-input>
  71. <el-input
  72. :disabled="statusPop === 2"
  73. v-else
  74. v-model="listData[items.prop]"
  75. ></el-input>
  76. </el-form-item>
  77. </el-form>
  78. </div>
  79. <span slot="footer" class="dialog-footer">
  80. <el-button @click="close">取 消</el-button>
  81. <el-button
  82. type="primary"
  83. v-if="statusPop !== 2"
  84. @click="submit('listData')"
  85. >确 定</el-button
  86. >
  87. </span>
  88. </el-dialog>
  89. </div>
  90. </template>
  91. <script>
  92. import searchBox from "@/components/searchBox";
  93. import tableList from "@/components/tableList";
  94. import pagination from "@/components/pagination";
  95. export default {
  96. components: { searchBox, tableList, pagination },
  97. data() {
  98. return {
  99. loading: false, //当前表单加载是否加载动画
  100. navText: {
  101. title: "试卷类型",
  102. index: 0,
  103. ch: "条",
  104. num: true,
  105. choice: true,
  106. addHide: false,
  107. backFatherBtn: {
  108. status: false,
  109. title: "未定义",
  110. },
  111. },
  112. // 表单
  113. tableSet: [
  114. {
  115. label: "试卷类型编码",
  116. prop: "encoder",
  117. hidden: true,
  118. },
  119. {
  120. label: "试卷类型名称",
  121. prop: "paperName",
  122. hidden: true,
  123. scope: 'editInfo'
  124. },
  125. {
  126. label: "状态",
  127. prop: "status",
  128. hidden: true,
  129. scope: "status",
  130. },
  131. ],
  132. tableData: [], //表单数据
  133. total: 0, //一共多少条
  134. pageSize: 10, //每页多少条数据
  135. currentPage: 1, //当前页码
  136. // 弹窗字段
  137. listitem: [
  138. {
  139. label: "试卷类型名称",
  140. prop: "paperName",
  141. },
  142. {
  143. label: "状态",
  144. prop: "status",
  145. scope: "status",
  146. options: [
  147. {
  148. label: "启用",
  149. value: 1,
  150. },
  151. {
  152. label: "关闭",
  153. value: 0,
  154. },
  155. ],
  156. },
  157. {
  158. label: "备注",
  159. prop: "remark",
  160. scope: "textarea",
  161. },
  162. ],
  163. // 弹窗数据
  164. listData: {},
  165. statusPop: -1,
  166. dialogVisible: false,
  167. //表单验证
  168. rules: {
  169. paperName: [
  170. { required: true, message: "请输入试卷类型名称", trigger: "blur" },
  171. ],
  172. status: [{ required: true, message: "请选择状态", trigger: "change" }],
  173. },
  174. };
  175. },
  176. mounted() {
  177. this.search();
  178. },
  179. methods: {
  180. editInfo(v){
  181. this.addClick(v,0)
  182. },
  183. search(v) {
  184. this.loading = true;
  185. var data = {
  186. status:'0,1',
  187. pageSize: this.pageSize,
  188. pageNum: this.currentPage,
  189. };
  190. this.$api.inquirepaperexamList(data).then((res) => {
  191. this.tableData = res.rows;
  192. this.total = res.total;
  193. this.navText.index = res.total;
  194. }).finally(()=>{
  195. this.loading = false;
  196. })
  197. },
  198. init() {
  199. this.search();
  200. },
  201. del(v) {
  202. this.$alert(
  203. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  204. "提示",
  205. {
  206. dangerouslyUseHTMLString: true,
  207. }
  208. )
  209. .then(() => {
  210. var data = {
  211. id: v.id,
  212. status: -1,
  213. };
  214. this.$api.editpaperexam(data).then((res) => {
  215. this.$message.success("删除成功");
  216. this.search();
  217. });
  218. })
  219. .catch(() => {
  220. this.$message({
  221. type: "info",
  222. message: "已取消删除",
  223. });
  224. });
  225. },
  226. addClick(v, int) {
  227. if (v === undefined) {
  228. this.statusPop = 1;
  229. this.listData = {
  230. status: 1,
  231. };
  232. } else {
  233. this.statusPop = int;
  234. this.listData = JSON.parse(JSON.stringify(v));
  235. }
  236. this.$nextTick(() => {
  237. this.$refs.listData.clearValidate();
  238. });
  239. this.dialogVisible = true;
  240. },
  241. submit(formName) {
  242. this.$refs[formName].validate((valid) => {
  243. if (valid) {
  244. this.rulesTableSumbit();
  245. } else {
  246. return false;
  247. }
  248. });
  249. },
  250. rulesTableSumbit() {
  251. if (this.statusPop === 1) {
  252. this.$api.addpaperexam(this.listData).then((res) => {
  253. this.$message.success("新增成功");
  254. this.dialogVisible = false;
  255. this.search();
  256. });
  257. }
  258. if (this.statusPop === 0) {
  259. this.$api.editpaperexam(this.listData).then((res) => {
  260. this.$message.success("修改成功");
  261. this.dialogVisible = false;
  262. this.search();
  263. });
  264. }
  265. },
  266. close() {
  267. this.dialogVisible = false;
  268. },
  269. handleSizeChange(v) {
  270. this.pageSize = v;
  271. this.currentPage = 1;
  272. this.search();
  273. },
  274. handleCurrentChange(v) {
  275. this.currentPage = v;
  276. this.search();
  277. },
  278. },
  279. };
  280. </script>
  281. <style lang="less" scoped>
  282. /deep/.el-button {
  283. border-radius: 8px;
  284. }
  285. /deep/.el-dialog {
  286. border-radius: 8px;
  287. .el-dialog__header {
  288. padding: 0;
  289. .hearders {
  290. height: 40px;
  291. display: flex;
  292. align-items: center;
  293. justify-content: space-between;
  294. padding: 0px 18px 0px 20px;
  295. border-bottom: 1px solid #e2e2e2;
  296. .leftTitle {
  297. font-size: 14px;
  298. font-weight: bold;
  299. color: #2f4378;
  300. }
  301. .rightBoxs {
  302. display: flex;
  303. align-items: center;
  304. img {
  305. width: 14px;
  306. height: 14px;
  307. margin-left: 13px;
  308. cursor: pointer;
  309. }
  310. }
  311. }
  312. }
  313. .el-dialog__footer {
  314. padding: 0;
  315. .dialog-footer {
  316. padding: 0px 40px;
  317. height: 70px;
  318. border-top: 1px solid #e2e2e2;
  319. display: flex;
  320. align-items: center;
  321. justify-content: flex-end;
  322. }
  323. }
  324. }
  325. .imgBox {
  326. width: 100%;
  327. // height: 210px;
  328. border: 1px solid #e2e2e2;
  329. border-radius: 8px;
  330. padding: 8px 8px 3px;
  331. display: flex;
  332. flex-direction: column;
  333. align-items: center;
  334. .imgLabel {
  335. flex: 1;
  336. width: 100%;
  337. border: 1px dotted #e2e2e2;
  338. color: #999;
  339. font-size: 14px;
  340. cursor: pointer;
  341. border-radius: 8px;
  342. .msPhoto {
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. max-width: 100%;
  347. max-height: 270px;
  348. img {
  349. max-width: 100%;
  350. max-height: 270px;
  351. }
  352. }
  353. .imgbbx {
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. justify-content: center;
  358. width: 100%;
  359. height: 100%;
  360. i {
  361. font-weight: bold;
  362. margin: 14px 0;
  363. font-size: 24px;
  364. }
  365. }
  366. }
  367. p {
  368. margin: 5px 0px;
  369. }
  370. }
  371. </style>