更新细节
This commit is contained in:
parent
ffef7fc1db
commit
9cca6e0b99
|
@ -7,7 +7,7 @@ export function getUserList(params: any) {
|
|||
|
||||
// 产品列表列表
|
||||
export function apiProductLists(params: any) {
|
||||
return request.get({ url: '/land.product/lists', params })
|
||||
return request.get({ url: '/land.product/datas', params })
|
||||
}
|
||||
|
||||
// 土地表列表
|
||||
|
|
|
@ -23,18 +23,17 @@
|
|||
<el-form-item label="绑定产品" prop="product_id">
|
||||
<el-select
|
||||
v-model="formData.product_id"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
filterable
|
||||
placeholder="请输入产品信息"
|
||||
:remote-method="queryProduct"
|
||||
:loading="loading"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
v-for="(item, index) in optionsData.product"
|
||||
:key="index"
|
||||
:label="item.productinfo"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -44,6 +43,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup name="landEdit">
|
||||
import { useDictOptions } from '@/hooks/useDictOptions'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiLandBind, apiProductLists } from '@/api/land'
|
||||
|
@ -91,37 +91,29 @@ const setFormData = async (data: Record<any, any>) => {
|
|||
}
|
||||
}
|
||||
|
||||
interface ListItem {
|
||||
value: string
|
||||
label: string
|
||||
const { optionsData } = useDictOptions<{
|
||||
product: any[]
|
||||
}>({
|
||||
product: {
|
||||
api: apiProductLists
|
||||
}
|
||||
const productOptions = ref<ListItem[]>([])
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const queryProduct = async (query: string) => {
|
||||
if (query) {
|
||||
const queryProduct = async (land_id: string) => {
|
||||
loading.value = true
|
||||
const productList = await apiProductLists({
|
||||
name: query
|
||||
land_id: land_id ?? ''
|
||||
})
|
||||
optionsData.product = productList
|
||||
loading.value = false
|
||||
if (productList.count > 0) {
|
||||
productOptions.value = productList.lists.map((product: any) => {
|
||||
return { value: `${product.id}`, label: `ID: ${product.id} / 名称: ${product.name}` }
|
||||
})
|
||||
} else {
|
||||
productOptions.value = []
|
||||
}
|
||||
loading.value = false
|
||||
} else {
|
||||
productOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data = { ...formData, }
|
||||
const data = { ...formData }
|
||||
await apiLandBind(data)
|
||||
popupRef.value?.close()
|
||||
emit('success')
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<el-table-column label="剩余面积" prop="residual_area" show-overflow-tooltip />
|
||||
<el-table-column label="土地负责人" prop="master_name" show-overflow-tooltip />
|
||||
<el-table-column label="负责人电话" prop="master_phone" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="360" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="400" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['land.land/edit']"
|
||||
|
@ -64,14 +64,14 @@
|
|||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<!-- <el-button
|
||||
<el-button
|
||||
v-perms="['land.land/bind']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleBind(row)"
|
||||
>
|
||||
绑定产品
|
||||
</el-button> -->
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['land.product/lists']"
|
||||
type="primary"
|
||||
|
|
|
@ -42,6 +42,11 @@ class ProductController extends BaseAdminController
|
|||
return $this->dataLists(new ProductLists());
|
||||
}
|
||||
|
||||
public function datas()
|
||||
{
|
||||
$datas = (new ProductLogic())->datas(input(''));
|
||||
return $this->success('', $datas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
|
|
|
@ -153,7 +153,7 @@ class LandLogic extends BaseLogic
|
|||
->order('id desc')
|
||||
->select()->toArray();
|
||||
foreach ($lists as &$item) {
|
||||
$item['landinfo'] = $item['id'] . ' / ' . $item['title'];
|
||||
$item['landinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['title'];
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
@ -186,9 +186,10 @@ class LandLogic extends BaseLogic
|
|||
|
||||
public static function bind($params): bool
|
||||
{
|
||||
$root = (request()->adminInfo)['root'];
|
||||
$userId = (request()->adminInfo)['user_id'];
|
||||
if (!empty($params['id'])) {
|
||||
$userId = Db::name('land')->where('id', $params['id'])->value('user_id');
|
||||
if ($root && !empty($params['user_id'])) {
|
||||
$userId = $params['user_id'];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
|
|
@ -128,6 +128,36 @@ class ProductLogic extends BaseLogic
|
|||
}
|
||||
}
|
||||
|
||||
public function datas($params): array
|
||||
{
|
||||
$userWhere['p.user_id'] = -1;
|
||||
if (!empty($params['user_id'])) {
|
||||
$userWhere['p.user_id'] = $params['user_id'];
|
||||
}
|
||||
if (!request()->adminInfo['root'] && request()->adminInfo['user_id']) {
|
||||
$userWhere['p.user_id'] = request()->adminInfo['user_id'];
|
||||
}
|
||||
if (request()->adminInfo['root']) {
|
||||
unset($userWhere['p.user_id']);
|
||||
}
|
||||
$queryWhere = [];
|
||||
if (!empty($params['land_id'])) {
|
||||
$queryWhere['l.id'] = $params['land_id'];
|
||||
}
|
||||
$productIdArray = Db::name('land_product')->column('product_id');
|
||||
$lists = Db::name('product')->alias('p')
|
||||
->where($userWhere)->whereNotIn('p.id', $productIdArray)
|
||||
->leftJoin('user u','u.id = p.user_id')
|
||||
->field('p.*')
|
||||
->limit(0, 100)
|
||||
->order(['p.id' => 'desc'])
|
||||
->select()->toArray();
|
||||
foreach ($lists as &$item) {
|
||||
$item['productinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['name'];
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
|
|
|
@ -73,7 +73,7 @@ class UserLogic extends BaseLogic
|
|||
->order('id desc')
|
||||
->select()->toArray();
|
||||
foreach ($lists as &$item) {
|
||||
$item['userinfo'] = $item['id'] . ' / ' . $item['account'];
|
||||
$item['userinfo'] = 'ID:' . $item['id'] . ' / 账户:' . $item['account'];
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue