|
@@ -67,7 +67,7 @@
|
|
|
<el-icon @click.stop="handleEdit(item.kk_id)">
|
|
|
<EditPen />
|
|
|
</el-icon>
|
|
|
- <el-icon @click.stop="handleAddChapter(item.kk_id)" style="margin-left: 20px;" v-if="item.kc_cate_level_2=='11'">
|
|
|
+ <el-icon @click.stop="handleAddChapter(item.kk_id)" style="margin-left: 20px;" v-if="item.is_wlzy=='1'">
|
|
|
<Plus/>
|
|
|
</el-icon>
|
|
|
<el-icon @click.stop="handleDelete(item.kk_id)" style="margin-left: 20px;">
|
|
@@ -88,24 +88,29 @@
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
- <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
|
|
|
+ <el-dialog v-model="dialogFormVisibleChapter" title="" width="25%">
|
|
|
+ <div class="" style="text-align: center; margin-bottom: 15px; font-size: 16px;">添加单元名称</div>
|
|
|
<el-form :model="chapterForm">
|
|
|
- <el-form-item label="活动名称" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="chapterForm.name" autocomplete="off"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="活动区域" :label-width="formLabelWidth">
|
|
|
- <el-select v-model="chapterForm.region" placeholder="请选择活动区域">
|
|
|
- <el-option label="区域一" value="shanghai"></el-option>
|
|
|
- <el-option label="区域二" value="beijing"></el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
+ <div class="singO" v-for="(item , index) in unitNames" :key="item.id">
|
|
|
+ <div class="singO_left">
|
|
|
+ <el-form-item :label="'单元名称' + (index+1)+':'" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="item.name" autocomplete="off" />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <div class="singO_right" ><el-button type="danger" @click="removeUnit(item.id)">删除</el-button></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
</el-form>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
|
|
|
+ <div style="text-align: left; border-top: 1px dashed #c9c9c9; box-sizing: border-box; padding-top: 10px;">
|
|
|
+ <el-button type="primary" @click="addUnit">添加</el-button>
|
|
|
</div>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisibleChapter = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="submitForm">提交</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
|
|
|
</div>
|
|
|
</template>
|
|
@@ -113,7 +118,7 @@
|
|
|
<script>
|
|
|
import { Delete, EditPen, Plus} from '@element-plus/icons-vue';
|
|
|
import { ElMessageBox } from 'element-plus'
|
|
|
-import { grade_list, subject_list, cate_list, kc_list, kc_delete } from "./api";
|
|
|
+import { grade_list, subject_list, cate_list, kc_list, kc_delete,attribAdd,attribDetail } from "./api";
|
|
|
import { getFullUrl } from '@/utils/helper';
|
|
|
import { user } from '~/store/user';
|
|
|
export default {
|
|
@@ -131,12 +136,15 @@ export default {
|
|
|
pageSize: 10,
|
|
|
currentPage: 1,
|
|
|
total: 0,
|
|
|
- dialogFormVisible: true,
|
|
|
+ kkId:'',
|
|
|
+ dialogFormVisibleChapter: false,
|
|
|
chapterForm: {
|
|
|
name: '',
|
|
|
- region: '',
|
|
|
},
|
|
|
- formLabelWidth: '120px',
|
|
|
+ formLabelWidth: '90px',
|
|
|
+ unitNum:1,
|
|
|
+ unitNum: [1], // 数组,用于循环添加单元
|
|
|
+ unitNames: [{ id: "", name: '' }] // 数组,用于保存所有单元的ID和名称的对象
|
|
|
}
|
|
|
},
|
|
|
components: { Delete, EditPen, Plus, ElMessageBox },
|
|
@@ -240,9 +248,66 @@ export default {
|
|
|
this.setStorage();
|
|
|
},
|
|
|
handleAddChapter(kkId) {
|
|
|
- // this.dialogFormVisible = true
|
|
|
- console.log('this',this);
|
|
|
- console.log('kkid', kkId);
|
|
|
+ this.unitNames = [];
|
|
|
+ this.kkId = kkId;
|
|
|
+ let transObj = {
|
|
|
+ kk_id:kkId,
|
|
|
+ }
|
|
|
+ attribDetail(transObj)
|
|
|
+ .then(res => {
|
|
|
+ if (res.code == '1') {
|
|
|
+ console.log('res', res);
|
|
|
+ let responseData = res.data.details;
|
|
|
+ responseData.forEach(item => {
|
|
|
+ this.unitNames.push(
|
|
|
+ { id: item.ka_id, name: item.ka_name}
|
|
|
+ )
|
|
|
+ })
|
|
|
+ this.dialogFormVisibleChapter = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log('err', err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addUnit() {
|
|
|
+ this.unitNum.push(this.unitNum.length + 1);
|
|
|
+ // const newId = Number(this.unitNames.length) + 1;
|
|
|
+ // const newId = Date.now();
|
|
|
+ this.unitNames.push({ id: '', name: '' }); // 每次添加单元时,为 unitNames 数组添加一个带有ID的对象
|
|
|
+ },
|
|
|
+ removeUnit(id) {
|
|
|
+ const index = this.unitNames.findIndex(item => item.id === id);
|
|
|
+ if (index !== -1) {
|
|
|
+ this.unitNames.splice(index, 1);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ submitForm() {
|
|
|
+ console.log('json', JSON.stringify(this.unitNames));
|
|
|
+ let transObj = {
|
|
|
+ kk_id:this.kkId,
|
|
|
+ kczy_attrib: this.unitNames.map(item => {
|
|
|
+ return {
|
|
|
+ ka_id: item.id,
|
|
|
+ ka_name:item.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log('transObj:', transObj);
|
|
|
+ attribAdd(transObj)
|
|
|
+ .then(res => {
|
|
|
+ if (res.code == '1') {
|
|
|
+ this.dialogFormVisibleChapter = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log('err', err);
|
|
|
+ })
|
|
|
+
|
|
|
+ return false
|
|
|
+ // 提交表单的逻辑
|
|
|
+ this.dialogFormVisibleChapter = false;
|
|
|
+ // 这里可以提交表单数据或执行其他逻辑
|
|
|
},
|
|
|
handleDelete(kk_id) {
|
|
|
ElMessageBox.confirm('是否确定删除当前课程?', '提示', {
|
|
@@ -279,7 +344,7 @@ export default {
|
|
|
sessionStorage.removeItem("subject_id");
|
|
|
sessionStorage.removeItem("kc_cate_level_1");
|
|
|
sessionStorage.removeItem("page");
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
this.initGradeData();
|
|
@@ -297,7 +362,12 @@ export default {
|
|
|
_this.initData();
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ filteredUnitNames() {
|
|
|
+ return this.unitNames.filter(item => item.id !== '');
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -459,4 +529,20 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.singO {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ .singO_left{
|
|
|
+ width: 80%;
|
|
|
+ }
|
|
|
+ .singO_right{
|
|
|
+ width: 20%;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+}
|
|
|
+.unit-row > .el-input {
|
|
|
+ flex: 1; /* 让输入框占据剩余空间 */
|
|
|
+ margin-right: 10px; /* 调整输入框和删除按钮之间的间距 */
|
|
|
+}
|
|
|
</style>
|