|
@@ -1,144 +0,0 @@
|
|
|
-<template>
|
|
|
|
|
- <el-dialog
|
|
|
|
|
- :title="title"
|
|
|
|
|
- :visible.sync="dialogVisible"
|
|
|
|
|
- width="30%"
|
|
|
|
|
- >
|
|
|
|
|
- <div class="content-container">
|
|
|
|
|
- <el-form ref="ruleForm" :model="formData" :rules="rules" label-width="100px">
|
|
|
|
|
-
|
|
|
|
|
- <el-form-item label="类别名称">
|
|
|
|
|
- <el-input v-model="formData.industryTypeTitle" placeholder="输入行业类型名称" />
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
-
|
|
|
|
|
- <el-form-item label="说明" prop="positionDesc">
|
|
|
|
|
- <el-input v-model="formData.industryTypeDesc" type="textarea" placeholder="输入说明" />
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-form>
|
|
|
|
|
- </div>
|
|
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
|
|
- <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
|
|
- <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
|
|
|
|
|
- </span>
|
|
|
|
|
- </el-dialog>
|
|
|
|
|
-</template>
|
|
|
|
|
-
|
|
|
|
|
-<script>
|
|
|
|
|
-import { ACTION_ADD, ACTION_UPDATE } from '@/utils/actionType'
|
|
|
|
|
-import { getIndustryTypeById, createIndustryType, updateIndustryType } from '@/api/system/industryTypeApi'
|
|
|
|
|
-
|
|
|
|
|
-export default {
|
|
|
|
|
- props: {
|
|
|
|
|
- title: {
|
|
|
|
|
- type: String,
|
|
|
|
|
- default: ''
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- dialogVisible: false,
|
|
|
|
|
- actionType: '',
|
|
|
|
|
- formData: {
|
|
|
|
|
- industryTypeId: undefined,
|
|
|
|
|
- industryTypeTitle: '',
|
|
|
|
|
- industryTypeDesc: ''
|
|
|
|
|
- },
|
|
|
|
|
- rules: {
|
|
|
|
|
- industryTypeTitle: [
|
|
|
|
|
- { required: true, message: '请填写名称', trigger: 'blur' }
|
|
|
|
|
- ]
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- methods: {
|
|
|
|
|
- formSuccess() {
|
|
|
|
|
- this.$emit('formSuccess')
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // Show Add Model
|
|
|
|
|
- showAddModel() {
|
|
|
|
|
- this.actionType = ACTION_ADD
|
|
|
|
|
- this.resetFormData()
|
|
|
|
|
- this.dialogVisible = true
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // Show Edit Model
|
|
|
|
|
- showEditModel(industryId) {
|
|
|
|
|
- this.actionType = ACTION_UPDATE
|
|
|
|
|
- this.resetFormData()
|
|
|
|
|
- this.dialogVisible = true
|
|
|
|
|
- getIndustryTypeById(industryId).then((resp) => {
|
|
|
|
|
- const { code, data } = resp
|
|
|
|
|
- if (code === 200) {
|
|
|
|
|
- this.formData = data
|
|
|
|
|
- }
|
|
|
|
|
- }).catch((error) => {
|
|
|
|
|
- console.log(error)
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // Reset Form Data
|
|
|
|
|
- resetFormData() {
|
|
|
|
|
- this.formData = {
|
|
|
|
|
- industryTypeId: undefined,
|
|
|
|
|
- industryTypeTitle: '',
|
|
|
|
|
- industryTypeDesc: ''
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // Submit
|
|
|
|
|
- submitForm(formName) {
|
|
|
|
|
- this.$refs[formName].validate((valid) => {
|
|
|
|
|
- if (valid) {
|
|
|
|
|
- this.handleActionCommand()
|
|
|
|
|
- } else {
|
|
|
|
|
- console.log('error submit!!')
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- // Handle ACTION Command
|
|
|
|
|
- handleActionCommand() {
|
|
|
|
|
- const actionType = this.actionType
|
|
|
|
|
- switch (actionType) {
|
|
|
|
|
- case ACTION_ADD:
|
|
|
|
|
- createIndustryType(this.formData).then((resp) => {
|
|
|
|
|
- const { code, msg } = resp
|
|
|
|
|
- if (code === 200) {
|
|
|
|
|
- this.$message.success(msg)
|
|
|
|
|
- this.dialogVisible = false
|
|
|
|
|
- this.formSuccess()
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.error(msg)
|
|
|
|
|
- }
|
|
|
|
|
- }).catch((error) => {
|
|
|
|
|
- console.log(error)
|
|
|
|
|
- })
|
|
|
|
|
- break
|
|
|
|
|
-
|
|
|
|
|
- case ACTION_UPDATE:
|
|
|
|
|
- updateIndustryType(this.formData).then((resp) => {
|
|
|
|
|
- const { code, msg } = resp
|
|
|
|
|
- if (code === 200) {
|
|
|
|
|
- this.dialogVisible = false
|
|
|
|
|
- this.formSuccess()
|
|
|
|
|
- this.$message.success(msg)
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.error(msg)
|
|
|
|
|
- }
|
|
|
|
|
- }).catch((error) => {
|
|
|
|
|
- console.log(error)
|
|
|
|
|
- })
|
|
|
|
|
- break
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-</script>
|
|
|
|
|
-
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
|
|
-
|
|
|
|
|
-</style>
|
|
|