更新细节

This commit is contained in:
yaooo 2023-12-06 13:45:44 +08:00
parent ffef7fc1db
commit 9cca6e0b99
7 changed files with 69 additions and 41 deletions

View File

@ -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 })
}
// 土地表列表

View File

@ -21,21 +21,20 @@
/>
</el-form-item>
<el-form-item label="绑定产品" prop="product_id">
<el-select
<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"
/>
<el-option
v-for="(item, index) in optionsData.product"
:key="index"
:label="item.productinfo"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
@ -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 productOptions = ref<ListItem[]>([])
const { optionsData } = useDictOptions<{
product: any[]
}>({
product: {
api: apiProductLists
}
})
const loading = ref(false)
const queryProduct = async (query: string) => {
if (query) {
loading.value = true
const productList = await apiProductLists({
name: query
})
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 queryProduct = async (land_id: string) => {
loading.value = true
const productList = await apiProductLists({
land_id: land_id ?? ''
})
optionsData.product = productList
loading.value = false
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
const data = { ...formData }
await apiLandBind(data)
popupRef.value?.close()
emit('success')

View File

@ -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"

View File

@ -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 添加

View File

@ -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 {

View File

@ -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 删除

View File

@ -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;
}