| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <!--
- * @Author: WangJiaCheng
- * @Date: 2021-05-11 11:18:32
- * @LastEditors: WangJiaCheng
- * @LastEditTime: 2021-07-29 16:04:02
- * @Description: 页面配置
- -->
- <template>
- <div class="page-edit">
- <el-form
- ref="pageForm"
- :rules="rules"
- :model="formData"
- label-width="120px"
- >
- <el-form-item label="页面Tab名称" prop="tabName">
- <el-input v-model="formData.tabName" />
- </el-form-item>
- <el-form-item label="Header 描述" prop="headerDesc">
- <el-input v-model="formData.headerDesc" />
- </el-form-item>
- <el-form-item label="Header 按钮">
- <el-tag
- v-for="tag in btnTags"
- :key="tag"
- closable
- :disable-transitions="false"
- @close="handleClose(tag)"
- >
- {{ tag }}
- </el-tag>
- <el-input
- v-if="inputVisible"
- ref="saveTagInput"
- v-model="inputValue"
- class="input-new-tag"
- size="small"
- @keyup.enter.native="handleInputConfirm"
- @blur="handleInputConfirm"
- />
- <el-button v-else class="button-new-tag" size="small" @click="showInput">
- 添加按钮
- </el-button>
- </el-form-item>
- <el-form-item label="路由" prop="route">
- <el-input v-model="formData.route" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="next">下一步</el-button>
- <el-button type="primary" @click="previewCode">预览入口组件代码</el-button>
- </el-form-item>
- </el-form>
- </div>
- </template>
- <script>
- import { mapMutations } from 'vuex'
- export default {
- name: 'PageConfig',
- data() {
- return {
- formData: {},
- rules: {
- tabName: [
- { required: true, message: '请输入Tab名称' }
- ],
- headerDesc: [
- { required: true, message: '请输入Header描述' }
- ]
- },
- btnTags: [],
- inputVisible: false,
- inputValue: ''
- }
- },
- methods: {
- ...mapMutations('page', ['setPageConfig', 'setActiveTab']),
- handleClose(tag) {
- this.btnTags.splice(this.btnTags.indexOf(tag), 1)
- },
- showInput() {
- this.inputVisible = true
- this.$nextTick(_ => {
- this.$refs.saveTagInput.$refs.input.focus()
- })
- },
- handleInputConfirm() {
- const { inputValue } = this
- if (inputValue) {
- this.btnTags.push(inputValue)
- }
- this.inputVisible = false
- this.inputValue = ''
- },
- next() {
- this.$refs.pageForm.validate(valid => {
- if (valid) {
- this.setPageConfig({ ...this.formData, btn: this.btnTags })
- this.setActiveTab('form')
- }
- })
- },
- previewCode() {
- this.$refs.pageForm.validate(valid => {
- if (valid) {
- this.$emit('preview', this.formData)
- }
- })
- }
- }
- }
- </script>
- <style lang="less">
- .page-edit {
- .el-tag + .el-tag {
- margin-left: 10px;
- }
- .button-new-tag {
- margin-left: 10px;
- height: 32px;
- line-height: 30px;
- padding-top: 0;
- padding-bottom: 0;
- }
- .input-new-tag {
- width: 90px;
- margin-left: 10px;
- vertical-align: bottom;
- }
- }
- </style>
|