rk
2025-08-21 37b1176f4b37260bd455891898ed1258c6421607
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<template>
  <GlobalWindow
    :title="title"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <el-form :model="form" ref="form" :rules="rules">
      <el-form-item label="名称" prop="name">
        <el-input v-if="form.type !=3"  v-model="form.name" placeholder="请输入名称" v-trim/>
        <el-select v-else  v-model="form.name" placeholder="请选择订单类型" v-trim>
          <el-option :value="'0'" label="用工单"></el-option>
          <el-option :value="'1'" label="货运单"></el-option>
          <el-option :value="'2'" label="订餐单"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item v-if="form.type ==3 " label="手续费(%)" prop="detail">
        <el-input  type="number"   v-model="form.detail" placeholder="请输入名称" v-trim/>
      </el-form-item>
      <el-form-item v-if="form.type == 1 || form.type == 2" :label=" form.type == 1?'车辆规格':'餐标配置(元)'" prop="detailList">
        <div style="display: flex;flex-direction: column">
          <div style="position: relative;display: block;width: 100%;" v-for="(item,index) in form.detailList"   >
            <el-input  :type="form.type == 1?'text':'number'" style="display:inline-block;width: 60%;margin:5px ;float: left" v-model="form.detailList[index]"   placeholder="请输入内容" v-trim/>
            <el-button  style="display:inline-block;margin : 5px " @click="del(index)" v-if="form.detailList.length>0">x</el-button>
          </div>
          <div style="position: relative;display: block;width: 100%;">
            <el-button style="width: 100px;margin: 5px;" type="primary" @click="add()">添加规格</el-button>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="form.type == 1" label="图标" prop="icon">
        <UploadAvatarImage
            :file="{ imgurlfull: form.iconFull, imgurl: form.icon }"
            :uploadData="uploadData"
            @uploadSuccess="uploadAvatarSuccess"
        />
      </el-form-item>
      <el-form-item  v-if="form.id ==null && form.type == 1"  label="是否固定车辆" prop="isFixed">
        <el-radio-group v-model="form.isFixed">
          <el-radio :label="0">非固定</el-radio>
          <el-radio :label="1">固定车型</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="排序码" prop="sortnum">
        <el-input v-model="form.sortnum" placeholder="请输入排序码" v-trim/>
      </el-form-item>
      <el-form-item label="描述" prop="remark">
        <el-input v-model="form.remark" placeholder="请输入描述" v-trim/>
      </el-form-item>
    </el-form>
  </GlobalWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import UploadAvatarImage from '@/components/common/UploadAvatarImage'
export default {
  name: 'OperaCategoryWindow',
  extends: BaseOpera,
  components: { GlobalWindow ,UploadAvatarImage},
  data () {
    return {
      isUploading: false,
      uploadData: {
        folder: 'category'
      },
      // 表单数据
      form: {
        id: null,
        status: 0,
        sortnum: null,
        name: '',
        type: null,
        detail: null,
        remark: null,
        detailList: [''],
        icon: '',
        iconFull: '',
        isFixed: 0
      },
      // 验证规则
      rules: {
        name: [{ required: true, message: '请输入配置名称' }]
      }
    }
  },
  created () {
    this.config({
      api: '/business/category',
      'field.id': 'id'
    })
  },
  methods:{
    del(index){
      if(this.form.detailList.length<=1){
        return
      }
      this.form.detailList.splice(index,1)
    },
    add(){
      this.form.detailList.push('')
    },
    uploadAvatarSuccess (file) {
      this.$set(this.form, 'icon', file.imgurl)
      this.$set(this.form, 'iconFull', file.imgurlfull)
    },
    open(title, target, type) {
      this.title = title
      this.visible = true
      this.form = {
        id: null,
        status: 0,
        sortnum: null,
        name: '',
        detail: null,
        type: type,
        remark: null,
        detailList: [''],
        icon: '',
        iconFull: '',
        isFixed: 0
      }
      // 新建
      if (target == null) {
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form[this.configData['field.id']] = null
          this.form.type = type
        })
        return
      }
      // 编辑
      this.$nextTick(() => {
        for (const key in this.form) {
          this.form[key] = target[key]
        }
        if(this.form.detailList==null){
          this.form.detailList = ['']
        }
      })
    }
  }
}
</script>