doum
2026-04-17 e078c42eda285fb3ec19f53c57cb4dc87c1d8fc1
admin/src/views/business/area.vue
@@ -24,11 +24,11 @@
        </el-table-column>
        <el-table-column prop="createDate" label="创建时间" align="center" min-width="140px"></el-table-column>
        <el-table-column prop="sortnum" label="排序" align="center" min-width="140px"></el-table-column>
        <el-table-column label="状态" align="center" min-width="140px">
        <el-table-column label="开通状态" align="center" min-width="140px">
          <template slot-scope="{ row }">
            <el-switch
            <el-switch v-if="row.type==1"
              v-model="row.status"
              active-color="#13ce66"
              active-color="green"
              inactive-color="#ff4949"
              active-value="1"
              inactive-value="0">
@@ -39,15 +39,19 @@
          v-if="containPermissions(['business:areas:update'])"
          label="操作"
          align="center"
          min-width="80"
          min-width="180"
        >
          <template slot-scope="{ row }">
            <el-button type="text" @click="openPriceRule(row)" v-if="row.type === 1">计价规则</el-button>
            <el-button type="text" @click="edit(row)" v-permissions="['business:areas:update']">编辑</el-button>
            <el-button v-if="row.type!=2" type="text" @click="createChild(row)" v-permissions="['business:areas:create']">新建{{ row.type==0 ? '市' : '区县' }}</el-button>
            <el-button type="text" style="color: red;" @click="deleteById(row)" v-permissions="['business:areas:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <OperaCityPriceRuleWindow ref="operaCityPriceRuleWindow" @success="handlePriceRuleSuccess"/>
    <OperaAreasWindow ref="operaAreasWindow" @success="update"/>
  </TableLayout>
</template>
@@ -57,10 +61,11 @@
import Pagination from '@/components/common/Pagination'
import { listByParentId } from '@/api/business/areas'
import OperaCityPriceRuleWindow from '@/components/business/OperaCityPriceRuleWindow'
import OperaAreasWindow from '@/components/business/OperaAreasWindow'
export default {
  name: 'Areas',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaCityPriceRuleWindow },
  components: { TableLayout, Pagination, OperaAreasWindow, OperaCityPriceRuleWindow },
  data () {
    return {
      // 搜索
@@ -96,18 +101,18 @@
          this.isWorking.search = false
        })
    },
    dataAddBool(array) {
    dataAddBool (array) {
      array.forEach(item => {
        item.hasChildren = item.type != 2
        // item.childList = item.childList && this.dataAddBool(item.childList)
      })
      return array
    },
    load(tree, treeNode, resolve) {
    load (tree, treeNode, resolve) {
      this.treeMaps.set(tree.id, { tree, treeNode, resolve })
      listByParentId({ parentId: tree.id, type: tree.type + 1 })
        .then(data => {
          resolve(this.dataAddBool(data||[]))
          resolve(this.dataAddBool(data || []))
        })
        .catch(e => {
          this.$tip.apiFailed(e)
@@ -116,7 +121,7 @@
          this.isWorking.search = false
        })
    },
    refreshLoadTree(parentId) {
    refreshLoadTree (parentId) {
      if (this.treeMaps.get(parentId)) {
        const { tree, treeNode, resolve } = this.treeMaps.get(parentId)
        this.$set(this.$refs.table.store.states.lazyTreeNodeMap, parentId, [])
@@ -131,14 +136,21 @@
        this.handlePageChange()
      }
    },
    update(parentId) {
    update (parentId) {
      this.refreshLoadTree(parentId)
    },
    openPriceRule(row) {
      this.$refs.operaCityPriceRuleWindow.open('计价规则', row.id)
    openPriceRule (row) {
      this.$refs.operaCityPriceRuleWindow.open('计价规则(' + (row.name || '') + ')', row.id)
    },
    handlePriceRuleSuccess() {
    handlePriceRuleSuccess () {
      this.$message.success('保存成功')
    },
    edit (row) {
      // this.parentId = row.type==0 ? null : row.type==1 ? '编辑市' : '编辑区县'
      this.$refs.operaAreasWindow.open(row.type == 0 ? '编辑省' : row.type == 1 ? '编辑市' : '编辑区县', row)
    },
    createChild (row) {
      this.$refs.operaAreasWindow.open(row.type == 0 ? '新建市' : '新建县区', { parentId: row.id, name: '', type: row.type === 1 ? 2 : 1 })
    }
  }
}