123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <div class="app-container">
- <div class="common-card">
- <!-- 新建类型 -->
- <div class="engineeringWork-create">
- <div class="engineeringWork-create-title">新建类型</div>
- <div class="engineeringWork-create-edit">
- <div class="engineeringWork-create-none"></div>
- <div class="engineeringWork-create-input">
- <span>类型名称:</span>
- <a-input
- v-model.trim="questionTypeName"
- placeholder="请输入试题类型"
- />
- </div>
- <a-button
- type="primary"
- :disabled="!questionTypeName.length"
- @click="engineeringWorkCreateFun"
- >新建</a-button
- >
- </div>
- </div>
- </div>
- <div class="common-card a-card-margin-top">
- <!-- 已有类型 -->
- <div class="engineeringWork-list">
- <div class="engineeringWork-list-title">已有类型</div>
- <a-table
- :columns="columns"
- :row-key="(record) => record.id"
- :data-source="tableData"
- :pagination="false"
- >
- <a
- slot="action"
- slot-scope="text, record"
- @click="engineeringWorkDelete(record)"
- >删除</a
- >
- </a-table>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { formatePathParams } from '@/filters';
- export default {
- name: 'examQuestionTypeCondition',
- props: {},
- components: {},
- data() {
- return {
- questionTypeName: '', // 新建试题类型的名称
- columns: [], // 表单配置
- tableData: [], // 列表数据
- };
- },
- created() {
- this.initDataFun(); //初始化数据
- },
- mounted() {},
- beforeDestroy() {},
- watch: {},
- computed: {},
- methods: {
- //初始化数据
- initDataFun() {
- // 表单配置
- this.columns = [
- {
- title: '试题类型',
- dataIndex: 'name',
- key: 'name',
- },
- {
- title: '操作',
- key: 'action',
- scopedSlots: { customRender: 'action' },
- width: 150,
- },
- ];
- this.getTableListFun(); // 查询:试题列表
- },
- // 查询:试题类型列表
- getTableListFun() {
- this.loading = true;
- this.$_http
- .get(this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE)
- .then((res) => {
- this.tableData = res.data;
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- },
- // 操作:新建试题类型
- engineeringWorkCreateFun() {
- this.loading = true;
- let params = {
- name: this.questionTypeName,
- parentId: null,
- };
- this.$_http
- .post(this.$_API.INTERFACE_POST_EXAMS_QUESTION_TYPE_CREATE, params)
- .then(() => {
- this.questionTypeName = '';
- this.loading = false;
- this.$message.success('新建试题类型成功');
- this.getTableListFun(); // 查询:试题类型列表
- })
- .catch(() => {
- this.loading = false;
- });
- },
- // 操作:删除试题类型
- engineeringWorkDelete(record) {
- this.loading = true;
- let params = {
- categoryId: record.id,
- };
- this.$_http
- .delete(
- formatePathParams(
- this.$_API.INTERFACE_POST_EXAMS_QUESTION_TYPE_DELETE,
- params
- )
- )
- .then(() => {
- this.loading = false;
- this.$message.success('删除试题类型成功');
- this.getTableListFun(); // 查询:试题类型列表
- })
- .catch(() => {
- this.loading = false;
- });
- },
- },
- };
- </script>
- <style lang="less"></style>
- <style lang="less" scoped>
- @import '~@/styles/common/variable.less';
- .app-container {
- overflow-y: auto;
- .engineeringWork-create {
- width: 100%;
- .engineeringWork-create-title {
- font-size: 18px;
- font-weight: bold;
- color: @mainColorBlack85;
- }
- .engineeringWork-create-edit {
- display: flex;
- .engineeringWork-create-none {
- width: 100px;
- }
- .engineeringWork-create-input {
- margin-right: 50px;
- display: flex;
- align-items: center;
- > span {
- font-size: 14px;
- flex-wrap: nowrap;
- white-space: nowrap;
- }
- }
- }
- }
- .engineeringWork-list {
- .engineeringWork-list-title {
- margin-bottom: @paddingMarginVal;
- font-size: 18px;
- font-weight: bold;
- color: @mainColorBlack85;
- }
- }
- }
- </style>
|