更新细节

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) { export function apiProductLists(params: any) {
return request.get({ url: '/land.product/lists', params }) return request.get({ url: '/land.product/datas', params })
} }
// 土地表列表 // 土地表列表

View File

@ -23,18 +23,17 @@
<el-form-item label="绑定产品" prop="product_id"> <el-form-item label="绑定产品" prop="product_id">
<el-select <el-select
v-model="formData.product_id" v-model="formData.product_id"
filterable
remote remote
reserve-keyword filterable
placeholder="请输入产品信息" placeholder="请输入产品信息"
:remote-method="queryProduct" :remote-method="queryProduct"
:loading="loading" :loading="loading"
> >
<el-option <el-option
v-for="item in productOptions" v-for="(item, index) in optionsData.product"
:key="item.value" :key="index"
:label="item.label" :label="item.productinfo"
:value="item.value" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -44,6 +43,7 @@
</template> </template>
<script lang="ts" setup name="landEdit"> <script lang="ts" setup name="landEdit">
import { useDictOptions } from '@/hooks/useDictOptions'
import type { FormInstance } from 'element-plus' import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue' import Popup from '@/components/popup/index.vue'
import { apiLandBind, apiProductLists } from '@/api/land' import { apiLandBind, apiProductLists } from '@/api/land'
@ -91,37 +91,29 @@ const setFormData = async (data: Record<any, any>) => {
} }
} }
interface ListItem { const { optionsData } = useDictOptions<{
value: string product: any[]
label: string }>({
product: {
api: apiProductLists
} }
const productOptions = ref<ListItem[]>([]) })
const loading = ref(false) const loading = ref(false)
const queryProduct = async (query: string) => { const queryProduct = async (land_id: string) => {
if (query) {
loading.value = true loading.value = true
const productList = await apiProductLists({ const productList = await apiProductLists({
name: query land_id: land_id ?? ''
}) })
optionsData.product = productList
loading.value = false 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 () => { const handleSubmit = async () => {
await formRef.value?.validate() await formRef.value?.validate()
const data = { ...formData, } const data = { ...formData }
await apiLandBind(data) await apiLandBind(data)
popupRef.value?.close() popupRef.value?.close()
emit('success') emit('success')

View File

@ -54,7 +54,7 @@
<el-table-column label="剩余面积" prop="residual_area" show-overflow-tooltip /> <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_name" show-overflow-tooltip />
<el-table-column label="负责人电话" prop="master_phone" 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 }"> <template #default="{ row }">
<el-button <el-button
v-perms="['land.land/edit']" v-perms="['land.land/edit']"
@ -64,14 +64,14 @@
> >
编辑 编辑
</el-button> </el-button>
<!-- <el-button <el-button
v-perms="['land.land/bind']" v-perms="['land.land/bind']"
type="primary" type="primary"
link link
@click="handleBind(row)" @click="handleBind(row)"
> >
绑定产品 绑定产品
</el-button> --> </el-button>
<el-button <el-button
v-perms="['land.product/lists']" v-perms="['land.product/lists']"
type="primary" type="primary"

View File

@ -42,6 +42,11 @@ class ProductController extends BaseAdminController
return $this->dataLists(new ProductLists()); return $this->dataLists(new ProductLists());
} }
public function datas()
{
$datas = (new ProductLogic())->datas(input(''));
return $this->success('', $datas);
}
/** /**
* @notes 添加 * @notes 添加

View File

@ -153,7 +153,7 @@ class LandLogic extends BaseLogic
->order('id desc') ->order('id desc')
->select()->toArray(); ->select()->toArray();
foreach ($lists as &$item) { foreach ($lists as &$item) {
$item['landinfo'] = $item['id'] . ' / ' . $item['title']; $item['landinfo'] = 'ID' . $item['id'] . ' / 名称:' . $item['title'];
} }
return $lists; return $lists;
} }
@ -186,9 +186,10 @@ class LandLogic extends BaseLogic
public static function bind($params): bool public static function bind($params): bool
{ {
$root = (request()->adminInfo)['root'];
$userId = (request()->adminInfo)['user_id']; $userId = (request()->adminInfo)['user_id'];
if (!empty($params['id'])) { if ($root && !empty($params['user_id'])) {
$userId = Db::name('land')->where('id', $params['id'])->value('user_id'); $userId = $params['user_id'];
} }
Db::startTrans(); Db::startTrans();
try { 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 删除 * @notes 删除

View File

@ -73,7 +73,7 @@ class UserLogic extends BaseLogic
->order('id desc') ->order('id desc')
->select()->toArray(); ->select()->toArray();
foreach ($lists as &$item) { foreach ($lists as &$item) {
$item['userinfo'] = $item['id'] . ' / ' . $item['account']; $item['userinfo'] = 'ID' . $item['id'] . ' / 账户:' . $item['account'];
} }
return $lists; return $lists;
} }