feat(admin): 新增师傅大厅筛选功能及表格布局组件

- 新增服务品类和服务类型筛选选项
- 新增订单距离筛选功能
- 新增admin-table-layout组件实现表格操作列固定
- 重构后台表格列布局,优化显示效果
- 新增位置相关工具函数及测试用例
- 升级版本号至1.0.89
这个提交包含在:
2026-11-19 14:39:28 +08:00
父节点 a608ef6506
当前提交 c37739656c
共有 50 个文件被更改,包括 572 次插入 和 405 次删除

查看文件

@@ -19,6 +19,28 @@
<!-- 优匠优服 橙白企业级品牌视觉引擎 -->
<link href="__CDN__/assets/css/theme-qibing-orange.css?v={$Think.config.site.version|htmlentities}" rel="stylesheet">
<style>
/* Keep actions visible inside the table's own horizontal scroll area. */
.bootstrap-table .fixed-table-body table { border-collapse: separate; border-spacing: 0; }
.bootstrap-table .fixed-table-body th.yjyf-table-operate,
.bootstrap-table .fixed-table-body td.yjyf-table-operate,
.bootstrap-table .fixed-table-header th.yjyf-table-operate {
position: sticky;
right: 0;
z-index: 2;
background: #fff;
white-space: nowrap;
box-shadow: -3px 0 6px rgba(0, 0, 0, .08);
}
.bootstrap-table .fixed-table-body th.yjyf-table-operate,
.bootstrap-table .fixed-table-header th.yjyf-table-operate { z-index: 3; background: #f7f8fa; }
.bootstrap-table .fixed-table-body .table-striped > tbody > tr:nth-of-type(odd) > td.yjyf-table-operate { background: #f9f9f9; }
.bootstrap-table .fixed-table-body .table-hover > tbody > tr:hover > td.yjyf-table-operate { background: #f5f5f5; }
/* Search controls wrap independently of the table's horizontal scrolling. */
.bootstrap-table .fixed-table-toolbar { height: auto; }
.bootstrap-table .commonsearch-table { max-width: 100%; }
</style>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
<script src="__CDN__/assets/js/html5shiv.js"></script>
@@ -28,4 +50,5 @@
var require = {
config: {$config|json_encode}
};
require.config.site.version += "-admin-list-20261119";
</script>

查看文件

@@ -541,34 +541,6 @@ class Master extends Base
}
$type = $this->request->param('type', 'all'); // all / fixed 一口价 / quote 师傅报价 / custom 用户自主定价
$buildBase = function () use ($catIds) {
$q = Db::name('order')->where('master_id', 0)
->where('status', 'in', [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING]);
if (!empty($catIds)) {
$q->where('cat_id', 'in', $catIds);
}
return $q;
};
$build = function () use ($buildBase, $type) {
$q = $buildBase();
if ($type === 'fixed') {
$q->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'fixed');
} elseif ($type === 'quote') {
$q->where('status', 'in', [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING])->where('price_type', 'quote');
} elseif ($type === 'custom') {
$q->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'custom');
}
return $q;
};
$counts = [
'all' => (int)$buildBase()->count(),
'fixed' => (int)$buildBase()->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'fixed')->count(),
'quote' => (int)$buildBase()->where('status', 'in', [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING])->where('price_type', 'quote')->count(),
'custom' => (int)$buildBase()->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'custom')->count(),
];
$masterRecord = $this->masterInfo();
$rawLat = $this->request->param('lat', '');
$rawLng = $this->request->param('lng', '');
@@ -603,6 +575,58 @@ class Master extends Base
$validCoordCond = $this->getValidOrderCoordSql();
$distFormula = $this->getDistanceSqlFormula();
// 选项来自真实启用字典;分类始终受师傅技能范围约束。
$categoryQuery = Db::name('service_cat')->field('id,name')->where('status', 'normal');
if (!empty($catIds)) {
$categoryQuery->where('id', 'in', $catIds);
}
$filterCategories = $categoryQuery->order('weigh desc,id asc')->select();
$filterTypes = Db::name('service_type')->field('code,name')->where('status', 'normal')->order('weigh desc,id asc')->select();
$categoryId = max(0, (int)$this->request->param('cat_id', 0));
$serviceType = trim((string)$this->request->param('service_type', ''));
$distanceRaw = $this->request->param('distance_km', '');
$distanceKm = $distanceRaw === '' ? 0 : (float)$distanceRaw;
$categoryAllowed = array_map('intval', array_column($filterCategories, 'id'));
$typeAllowed = array_column($filterTypes, 'code');
if ($categoryId && !in_array($categoryId, $categoryAllowed, true)) $this->error('所选服务品类不可用');
if ($serviceType !== '' && (!preg_match('/^[a-z0-9_]+$/', $serviceType) || !in_array($serviceType, $typeAllowed, true))) $this->error('所选服务类型不可用');
if ($distanceRaw !== '' && (!is_numeric($distanceRaw) || $distanceKm <= 0 || $distanceKm > 200)) $this->error('订单距离无效');
if ($distanceKm > 0 && !$hasLocation) $this->error('请先选择接单位置');
$distanceCondition = '';
if ($distanceKm > 0) {
$distanceExpression = str_replace([':h_lat1', ':h_lng1', ':h_lat2'], [(string)$userLat, (string)$userLng, (string)$userLat], $distFormula);
$distanceCondition = $validCoordCond . ' AND ' . $distanceExpression . ' <= ' . (string)$distanceKm;
}
$buildBase = function () use ($catIds, $categoryId, $serviceType, $distanceCondition) {
$q = Db::name('order')->where('master_id', 0)
->where('status', 'in', [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING]);
if (!empty($catIds)) $q->where('cat_id', 'in', $catIds);
if ($categoryId) $q->where('cat_id', $categoryId);
if ($serviceType !== '') {
// 订单快照记录每个商品的真实工项;历史订单缺少快照时不猜测。
$q->whereRaw("CASE WHEN JSON_VALID(goods_images) THEN JSON_CONTAINS(JSON_EXTRACT(goods_images, '$.goods_list[*].service_type'), JSON_QUOTE('" . $serviceType . "')) = 1 ELSE 0 END");
}
if ($distanceCondition !== '') $q->whereRaw($distanceCondition);
return $q;
};
$build = function () use ($buildBase, $type) {
$q = $buildBase();
if ($type === 'fixed') {
$q->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'fixed');
} elseif ($type === 'quote') {
$q->where('status', 'in', [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING])->where('price_type', 'quote');
} elseif ($type === 'custom') {
$q->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'custom');
}
return $q;
};
$counts = [
'all' => (int)$buildBase()->count(),
'fixed' => (int)$buildBase()->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'fixed')->count(),
'quote' => (int)$buildBase()->where('status', 'in', [OrderStatus::PENDING_ACCEPT, OrderStatus::QUOTING])->where('price_type', 'quote')->count(),
'custom' => (int)$buildBase()->where('status', OrderStatus::PENDING_ACCEPT)->where('price_type', 'custom')->count(),
];
// 真实定位场景下的当前所在城市识别:优先使用实时传入城市;若未传入,根据 35km 内最近已知坐标订单推断,绝不拿跨城注册地误判
$locationCity = '';
if ($hasLocation) {
@@ -741,9 +765,14 @@ class Master extends Base
$goodsName = '';
$addonServices = '';
$fallbackImg = '';
$serviceTypeNames = [];
if (!empty($row['goods_images'])) {
$parsed = json_decode((string)$row['goods_images'], true);
if (is_array($parsed) && !empty($parsed['goods_list']) && is_array($parsed['goods_list'])) {
foreach ($parsed['goods_list'] as $goodsItem) {
$itemType = is_array($goodsItem) ? trim((string)($goodsItem['service_type_name'] ?? '')) : '';
if ($itemType !== '') $serviceTypeNames[] = $itemType;
}
$firstItem = $parsed['goods_list'][0];
if (is_array($firstItem)) {
$goodsName = isset($firstItem['goods_name']) && is_string($firstItem['goods_name'])
@@ -773,7 +802,7 @@ class Master extends Base
$row['goods_name'] = $goodsName ?: $row['service_name'];
$row['addon_services'] = rtrim(str_replace(';', ' · ', (string)$addonServices), ' ·');
$row['goods_num'] = max(1, (int)($row['goods_num'] ?? 1));
$row['service_type_tag'] = (strpos((string)$row['service_name'], '修') !== false || strpos((string)$row['service_name'], '检') !== false) ? '维修' : '安装';
$row['service_type_tag'] = implode(' / ', array_unique($serviceTypeNames));
$img = !empty($row['service_image']) ? $row['service_image'] : $fallbackImg;
if (empty($img) && !empty($row['service_id']) && !empty($serviceImgMap[(int)$row['service_id']])) {
@@ -821,6 +850,7 @@ class Master extends Base
'location_source' => $reqHasValidCoord ? 'realtime' : ($dbHasValidCoord ? 'saved' : 'none'),
'location_city' => $locationCity,
'serve_radius' => $serveRadius,
'filter_options' => ['categories' => $filterCategories, 'service_types' => $filterTypes],
]);
}

查看文件

@@ -4,7 +4,7 @@ return array (
'name' => '优匠优服',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.88',
'version' => '1.0.89',
'timezone' => 'Asia/Shanghai',
'forbiddenip' => '',
'languages' =>

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'], function ($, undefined, Backend, Table, Form, Template, undefined) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form', 'template', 'cookie'], function ($, undefined, Backend, Table, TableLayout, Form, Template, undefined) {
$.cookie.prototype.defaults = {path: Config.moduleurl};
var Controller = {

查看文件

@@ -0,0 +1,33 @@
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery', 'table'], function ($) {
var configure = factory();
var original = $.fn.bootstrapTable;
var wrapped = function (options) {
if (options && typeof options === 'object') configure(options);
return original.apply(this, arguments);
};
$.extend(wrapped, original);
$.fn.bootstrapTable = wrapped;
return configure;
});
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
}
}(function () {
return function (options) {
if (!options || !Array.isArray(options.columns)) return options;
options.columns.forEach(function (columns) {
if (!Array.isArray(columns)) return;
columns.forEach(function (column) {
if (column.field !== 'operate') return;
var classes = (column.class || '').split(/\s+/).filter(Boolean);
if (classes.indexOf('yjyf-table-operate') === -1) classes.push('yjyf-table-operate');
column.class = classes.join(' ');
// Keep original cells and their handlers instead of cloning the table.
options.fixedColumns = false;
});
});
return options;
};
}));

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form', 'jstree'], function ($, undefined, Backend, Table, TableLayout, Form, undefined) {
//读取选中的条目
$.jstree.core.prototype.get_all_checked = function (full) {
var obj = this.get_selected(), i, j;

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form', 'template'], function ($, undefined, Backend, Table, TableLayout, Form, Template) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -26,20 +26,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '50px'},
{field: 'theme', title: '卡片主题', searchList: {"promo":"活动促销","brand":"平台实力","service":"服务主题"}, formatter: Table.api.formatter.label, custom: {promo: 'warning', brand: 'danger', service: 'primary'}},
{field: 'badge', title: __('Badge'), operate: 'LIKE'},
{
field: 'title',
title: '主标题 / 副标题',
operate: 'LIKE',
align: 'left',
formatter: function (v, row) {
var html = '<div><strong>' + Fast.api.escape(v || '-') + '</strong></div>';
if (row.subtitle) {
html += '<div class="text-muted" style="font-size:11.5px;">' + Fast.api.escape(row.subtitle) + '</div>';
}
return html;
}
},
{field: 'subtitle', title: __('Subtitle'), operate: 'LIKE', visible: false},
{field: 'title', title: '主标题', operate: 'LIKE', align: 'left'},
{field: 'subtitle', title: __('Subtitle'), operate: 'LIKE'},
{field: 'action_text', title: '按钮文案', operate: 'LIKE', formatter: function (v) { return v ? Fast.api.escape(v) : '<span class="text-muted">-</span>'; }},
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: function (v, row, index) {
return v ? Table.api.formatter.image.call(this, v, row, index) : '<span class="text-muted">-</span>';

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
function syncCouponTypeInputs() {
var $type = $('#c-type');
@@ -56,20 +56,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'min_amount', title: '使用门槛', operate: 'BETWEEN', formatter: function (v) {
return Number(v) > 0 ? ('满 ¥' + Number(v).toFixed(2)) : '<span class="text-success">无门槛</span>';
}},
{field: 'total', title: '领取 / 总量', operate: false, formatter: function (v, row) {
var claimed = row.real_claimed !== undefined ? row.real_claimed : (row.received || 0);
return '<strong>' + claimed + '</strong> / ' + (v || 0);
}},
{field: 'real_claimed', title: '已领取', operate: false},
{field: 'total', title: '发行总量', operate: false},
{field: 'used_count', title: '已核销', operate: false, formatter: function (v) {
return Number(v) > 0 ? '<span class="label label-success">' + v + ' 张</span>' : '<span class="text-muted">0 张</span>';
}},
{field: 'end_time', title: '有效期限', operate: false, formatter: function (v, row) {
var now = Math.floor(Date.now() / 1000);
var s = row.start_time ? Table.api.formatter.datetime.call({datetimeFormat: 'YYYY-MM-DD'}, row.start_time) : '-';
var e = v ? Table.api.formatter.datetime.call({datetimeFormat: 'YYYY-MM-DD'}, v) : '-';
var expired = v && Number(v) < now ? ' <span class="label label-default">已到期</span>' : '';
return '<small>' + s + ' ~ ' + e + '</small>' + expired;
}},
{field: 'start_time', title: '开始时间', operate: false, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD'},
{field: 'end_time', title: '结束时间', operate: false, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD'},
{field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var ORDER_MODE_MAP = {
all: '不限订单类型',
@@ -258,19 +258,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: '编号', width: '68px', sortable: true, operate: false},
{
field: 'name',
title: '规则名称',
align: 'left',
operate: 'LIKE',
formatter: function (v, row) {
var html = '<strong>' + Fast.api.escape(v || '') + '</strong>';
if (row.remark) {
html += '<div class="text-muted" style="font-size:11.5px;">' + Fast.api.escape(row.remark) + '</div>';
}
return html;
}
},
{field: 'name', title: '规则名称', align: 'left', operate: 'LIKE'},
{field: 'remark', title: '备注', operate: false, visible: false},
{
field: 'conditions_preview',
title: '适用条件',

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'backend/admin-table-layout'], function ($, undefined, Backend, Form, Table) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form', 'upload'], function ($, undefined, Backend, Table, TableLayout, Form, Upload) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -24,48 +24,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '55px'},
{field: 'invoice_sn', title: '申请单号', operate: 'LIKE'},
{
field: 'title',
title: '发票抬头 / 税号',
operate: 'LIKE',
align: 'left',
formatter: function (v, row) {
var html = '<div><strong>' + Fast.api.escape(v || '-') + '</strong></div>';
if (row.tax_no) {
html += '<div class="text-muted" style="font-size:11.5px;font-family:monospace;">' + Fast.api.escape(row.tax_no) + '</div>';
}
return html;
}
},
{field: 'title', title: '发票抬头', operate: 'LIKE', align: 'left'},
{field: 'tax_no', title: '税号', operate: 'LIKE', visible: false},
{field: 'title_type', title: '抬头类型', searchList: {"personal":__('Personal'),"enterprise":__('Enterprise')}, visible: false},
{field: 'type', title: '发票类型', searchList: {"normal":__('Ordinary'),"special":__('Special')}, formatter: Table.api.formatter.label, custom: {normal: 'info', special: 'warning'}},
{field: 'amount', title: '开票金额', operate: 'BETWEEN', formatter: function (v, row) {
var ordTxt = Number(row.order_count) > 0 ? (row.order_count + ' 笔工单') : '按额度';
return '<strong class="text-danger">¥' + Number(v || 0).toFixed(2) + '</strong><div class="text-muted" style="font-size:11px;">' + ordTxt + '</div>';
}},
{
field: 'merchant.name',
title: '申请主体 / 邮箱',
operate: 'LIKE',
align: 'left',
formatter: function (value, row) {
var nick = (row.user && row.user.nickname) ? Fast.api.escape(row.user.nickname) : '';
var main = value ? ('<strong>' + Fast.api.escape(value) + '</strong>') : (nick || '<span class="text-muted">个人用户</span>');
var sub = row.email ? Fast.api.escape(row.email) : (nick && value ? nick : '-');
return '<div>' + main + '</div><div class="text-muted" style="font-size:11.5px;">' + sub + '</div>';
}
},
{field: 'user.nickname', title: '申请用户', operate: 'LIKE', visible: false},
{field: 'amount', title: '开票金额', operate: 'BETWEEN'},
{field: 'merchant.name', title: '申请企业', operate: 'LIKE', align: 'left'},
{field: 'user.nickname', title: '申请用户', operate: 'LIKE'},
{field: 'email', title: '接收邮箱', operate: 'LIKE', visible: false},
{field: 'status', title: '处理状态', searchList: {"wait":__('Wait'),"issued":__('Issued'),"reject":__('Reject'),"cancel":__('Cancel')}, formatter: Table.api.formatter.status, custom: {wait: 'warning', issued: 'success', reject: 'danger', cancel: 'gray'}},
{field: 'invoice_no', title: '发票号码 / 附件', operate: 'LIKE', formatter: function (v, row) {
var html = v ? ('<code>' + Fast.api.escape(v) + '</code>') : '<span class="text-muted">-</span>';
if (row.invoice_file) {
html += ' <a href="' + Fast.api.cdnurl(row.invoice_file) + '" target="_blank" class="btn btn-xs btn-info"><i class="fa fa-file-pdf-o"></i> 电子票</a>';
}
return html;
}},
{field: 'invoice_no', title: '发票号码', operate: 'LIKE'},
{field: 'invoice_file', title: '电子票', operate: false, formatter: function (v) { return v ? '<a href="' + Fast.api.escape(Fast.api.cdnurl(v)) + '" target="_blank" rel="noopener">查看</a>' : '—'; }},
{field: 'audit_msg', title: '处理说明', operate: 'LIKE', visible: false},
{field: 'createtime', title: '申请时间', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, width: '145px'},
{field: 'operate', title: '操作', table: table, events: Table.api.events.operate,

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -38,11 +38,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}},
{field: 'user.nickname', title: '维护用户', operate: 'LIKE'},
{field: 'email', title: '接收邮箱', operate: 'LIKE', formatter: function (v) { return v ? Fast.api.escape(v) : '-'; }},
{field: 'issued_count', title: '累计已开票', operate: false, formatter: function (v, row) {
var n = Number(v || 0);
if (!n) return '<span class="text-muted">0 笔</span>';
return '<span class="label label-success">' + n + ' 笔</span> <small class="text-danger">¥' + Number(row.issued_amount || 0).toFixed(2) + '</small>';
}},
{field: 'issued_count', title: '已开票数', operate: false},
{field: 'issued_amount', title: '已开票金额', operate: false},
{field: 'updatetime', title: '更新时间', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, width: '150px'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -38,15 +38,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '55px'},
{
field: 'realname',
title: '师傅姓名 / 等级',
operate: 'LIKE',
align: 'left',
formatter: function (val, row) {
return '<strong>' + (val || '-') + '</strong> <span class="label label-default">LV.' + (row.level || 1) + '</span>';
}
},
{field: 'realname', title: '师傅姓名', operate: 'LIKE', align: 'left'},
{field: 'level', title: '等级', operate: false},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{field: 'city', title: '驻地城市', operate: 'LIKE'},
{
@@ -73,7 +66,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
operate: 'BETWEEN',
sortable: true,
formatter: function (val) {
return '<span style="color:#d97706;font-weight:700;"><i class="fa fa-star"></i> ' + (val || '5.0') + '</span>';
return '<span style="color:#d97706;font-weight:700;"><i class="fa fa-star"></i> ' + (val === null || val === undefined || val === '' ? '—' : val) + '</span>';
}
},
{field: 'order_count', title: '完工单数', sortable: true},

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -32,16 +32,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '60px'},
{
field: 'master.realname',
title: '申报师傅',
operate: 'LIKE',
formatter: function (v, row) {
var mobile = (row.master && row.master.mobile) ? row.master.mobile : '';
return '<strong>' + Fast.api.escape(v || '-') + '</strong>' + (mobile ? '<div class="text-muted" style="font-size:11px;">' + Fast.api.escape(mobile) + '</div>' : '');
}
},
{field: 'master.mobile', title: '师傅电话', operate: 'LIKE', visible: false},
{field: 'master.realname', title: '申报师傅', operate: 'LIKE'},
{field: 'master.mobile', title: '师傅电话', operate: 'LIKE'},
{
field: 'cert_name',
title: '证书名称',

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -33,27 +33,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '55px'},
{
field: 'name',
title: '企业名称 / 信用代码',
operate: 'LIKE',
align: 'left',
formatter: function (val, row) {
return '<div><strong>' + (val || '-') + '</strong></div><div class="text-muted" style="font-size:11.5px;font-family:monospace;">' + (row.license_no || '-') + '</div>';
}
},
{field: 'name', title: '企业名称', operate: 'LIKE', align: 'left'},
{field: 'license_no', title: __('License_no'), operate: 'LIKE', visible: false},
{field: 'legal_person', title: '法人代表', operate: 'LIKE'},
{
field: 'contact',
title: '业务对接人',
operate: 'LIKE',
align: 'left',
formatter: function (val, row) {
return '<div>' + (val || '-') + '</div><div class="text-muted" style="font-size:11.5px;">' + (row.mobile || '') + '</div>';
}
},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE', visible: false},
{field: 'contact', title: '业务对接人', operate: 'LIKE', align: 'left'},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{field: 'city', title: '所在城市', operate: 'LIKE'},
{
field: 'settle_type',
@@ -65,14 +49,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
: '<span class="label label-info">预付现结</span>';
}
},
{
field: 'order_count',
title: '发包单数 / 成交额',
operate: false,
formatter: function (val, row) {
return '<strong>' + (val || 0) + ' 单</strong> · <span style="color:#ea580c;font-weight:600;">¥' + (row.total_amount || '0.00') + '</span>';
}
},
{field: 'order_count', title: '发包单数', operate: false},
{field: 'total_amount', title: '成交额', operate: false},
{
field: 'member_count',
title: '协同员工',

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
function bindReceiveTypeToggle() {
$(document).off('change.msg changed.bs.select.msg', '#c-receive_type').on('change.msg changed.bs.select.msg', '#c-receive_type', function () {
@@ -41,16 +41,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '60px'},
{field: 'receive_type', title: '接收端', searchList: {"user":__('User'),"master":__('Master')}, formatter: Table.api.formatter.label, custom: {user: 'info', master: 'warning'}},
{field: 'receiver_name', title: '接收人', operate: false, formatter: function (v, row) {
var mob = row.receiver_mobile ? ' <small class="text-muted">(' + Fast.api.escape(row.receiver_mobile) + ')</small>' : '';
return '<strong>' + Fast.api.escape(v || '-') + '</strong>' + mob;
}},
{field: 'receiver_name', title: '接收人', operate: false},
{field: 'receiver_mobile', title: '接收电话', operate: false},
{field: 'type', title: __('Type'), searchList: {"order":__('Order'),"system":__('System'),"audit":__('Audit'),"remind":__('Remind')}, formatter: Table.api.formatter.label, custom: {order: 'primary', system: 'info', audit: 'warning', remind: 'success'}},
{field: 'order_no', title: '关联工单', operate: false, formatter: function (v) {
return v ? '<code>' + Fast.api.escape(v) + '</code>' : '<span class="text-muted">-</span>';
}},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'content', title: __('Content'), visible: false, operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'is_read', title: __('Is_read'), searchList: {"0":"未读","1":"已读"}, formatter: Table.api.formatter.label, custom: {"0": 'warning', "1": 'success'}},
{field: 'createtime', title: '发送时间', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, width: '150px'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var escapeText = function (value) {
if (value === null || value === undefined || value === '') return '—';

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -25,43 +25,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: 'ID', sortable: true, operate: false, visible: false},
{field: 'out_trade_no', title: '商户支付单号', align: 'left', operate: 'LIKE', formatter: function (value, row) {
if (!value) return '-';
var sceneMap = {
'order': ['#2563eb', '#eff6ff', '订单支付'],
'quote': ['#0891b2', '#ecfeff', '报价支付'],
'diff': ['#d97706', '#fffbeb', '增项补差'],
'batch': ['#7c3aed', '#f5f3ff', '批次支付'],
'recharge': ['#c2410c', '#fff7ed', '用户充值']
};
var sc = sceneMap[row.scene] || ['#64748b', '#f8fafc', row.scene || ''];
var tag = sc[2] ? '<div style="margin-top:2px;"><span class="label" style="display:inline-block;padding:1px 5px;border-radius:3px;font-size:10.5px;font-weight:500;color:' + sc[0] + ';background:' + sc[1] + ';">' + sc[2] + '</span></div>' : '';
return '<span style="font-family:Menlo,Monaco,Consolas,monospace;font-size:11.5px;font-weight:600;color:#0f172a;">' + value + '</span>' + tag;
}},
{field: 'out_trade_no', title: '商户支付单号', align: 'left', operate: 'LIKE'},
{field: 'order.order_no', title: '关联订单', align: 'left', operate: 'LIKE', formatter: function (value, row) {
if (!value) return '<span class="text-muted">-</span>';
var service = row.order && row.order.service_name ? '<div style="font-size:11px;color:#64748b;max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' + row.order.service_name + '</div>' : '';
return '<a href="' + Fast.api.fixurl('order/detail/ids/' + row.order_id) + '" class="dialogit" data-title="订单详情" style="font-family:Menlo,Monaco,Consolas,monospace;font-size:11.5px;font-weight:600;color:#2563eb;">' + value + '</a>' + service;
return value ? '<a href="' + Fast.api.fixurl('order/detail/ids/' + row.order_id) + '" class="dialogit" data-title="订单详情">' + Fast.api.escape(value) + '</a>' : '—';
}},
{field: 'user.nickname', title: '支付用户', operate: 'LIKE', formatter: function (value, row) {
if (!value && (!row.user || !row.user.username)) return '<span class="text-muted">-</span>';
var name = value || (row.user ? row.user.username : '');
var mobile = row.user && row.user.mobile ? '<div style="font-size:11px;color:#64748b;font-family:monospace;">' + row.user.mobile + '</div>' : '';
return '<strong>' + name + '</strong>' + mobile;
{field: 'user.nickname', title: '支付用户', operate: 'LIKE'},
{field: 'scene', title: '业务场景', operate: '=', searchList: {'order': '订单支付', 'quote': '报价支付', 'diff': '增项补差', 'batch': '批次支付', 'recharge': '用户在线充值'}, formatter: function (value) {
var labels = {'order': '订单支付', 'quote': '报价支付', 'diff': '增项补差', 'batch': '批次支付', 'recharge': '用户在线充值'};
return Fast.api.escape(labels[value] || value || '');
}},
{field: 'scene', title: '业务场景', operate: '=', visible: false, searchList: {'order': '订单支付', 'quote': '报价支付', 'diff': '增项补差', 'batch': '批次支付', 'recharge': '用户在线充值'}},
{field: 'amount', title: '实付金额', operate: false, align: 'right', formatter: function (value) {
return '<span style="font-family:Menlo,Monaco,Consolas,monospace;font-size:13px;font-weight:700;color:#F0710D;">¥' + value + '</span>';
}},
{field: 'refund_amount', title: '已退 / 余款', operate: false, align: 'right', formatter: function (value, row) {
var val = Number(value || 0).toFixed(2);
var left = (Number(row.amount) - Number(value)).toFixed(2);
var html = '<span style="font-family:Menlo,Monaco,Consolas,monospace;font-size:12px;font-weight:600;color:' + (val > 0 ? '#dc2626' : '#94a3b8') + ';">¥' + val + '</span>';
if (left > 0 && (row.status === 'paid' || row.status === 'refund_failed')) {
html += '<div style="font-size:11px;color:#16a34a;font-family:monospace;">余 ¥' + left + '</div>';
}
return html;
}},
{field: 'refund_amount', title: '已退款金额', operate: false, align: 'right'},
{field: 'status', title: '流水状态', operate: '=', searchList: {'pending': '待支付', 'paid': '已支付', 'pay_failed': '支付失败', 'refunded': '已退款', 'refunding': '退款处理中', 'refund_failed': '退款失败', 'closed': '已关闭'}, formatter: function (value, row) {
var map = {
'pending': ['#64748b', '#f1f5f9', '待支付'],
@@ -74,11 +50,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
};
var item = map[value] || ['#64748b', '#f1f5f9', value];
var html = '<span class="label" style="display:inline-block;padding:2px 8px;border-radius:12px;font-size:11.5px;font-weight:600;color:' + item[0] + ';background:' + item[1] + ';border:1px solid ' + item[0] + '33;">' + item[2] + '</span>';
if (row.refund_status && row.refund_status !== 'none') {
var rfMap = {'processing': '退款受理中', 'success': '已到账', 'abnormal': '退款异常', 'closed': '退款关闭'};
var rfTxt = rfMap[row.refund_status] || '';
if (rfTxt) html += '<div style="font-size:10.5px;color:#64748b;margin-top:2px;">' + rfTxt + '</div>';
}
return html;
}},
{field: 'refund_status', title: '退款单状态', operate: '=', visible: false, searchList: {'none': '未发起', 'processing': '退款受理中', 'success': '退款成功', 'abnormal': '退款异常', 'closed': '退款已关闭'}},

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
function parseTagArr(val) {
if (!val) return [];

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form', 'jstree'], function ($, undefined, Backend, Table, TableLayout, Form, undefined) {
//读取选中的条目
$.jstree.core.prototype.get_all_checked = function (full) {
var obj = this.get_selected(), i, j;

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {
@@ -34,16 +34,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '55px'},
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false, width: '65px'},
{
field: 'nickname',
title: '会员昵称 / 账号',
operate: 'LIKE',
align: 'left',
formatter: function (val, row) {
return '<div><strong>' + (val || '-') + '</strong></div><div class="text-muted" style="font-size:11.5px;">' + (row.username || '') + ' (ID:' + row.id + ')</div>';
}
},
{field: 'username', title: __('Username'), operate: 'LIKE', visible: false},
{field: 'nickname', title: '会员昵称', operate: 'LIKE', align: 'left'},
{field: 'username', title: __('Username'), operate: 'LIKE'},
{field: 'id', title: 'ID', operate: false, visible: false},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{
field: 'role_badges',
@@ -52,7 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
align: 'left',
formatter: function (val) {
if (!Array.isArray(val) || !val.length) {
return '<span class="label label-default">个人业主</span>';
return '—';
}
return val.map(function (b) {
var cls = b.type === 'master' ? 'warning' : (b.type === 'merchant' ? 'primary' : (b.type === 'member' ? 'info' : 'default'));

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'backend/admin-table-layout'], function ($, undefined, Backend, Form, Table) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'adminlte'], function ($, undefined, Backend, Table, Form, Adminlte) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form', 'adminlte'], function ($, undefined, Backend, Table, TableLayout, Form, Adminlte) {
var Controller = {
index: function () {

查看文件

@@ -1,4 +1,4 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) {
var Controller = {
index: function () {

14
tests/admin_table_layout.js 普通文件
查看文件

@@ -0,0 +1,14 @@
const assert = require('assert');
const configure = require('../server/public/assets/js/backend/admin-table-layout');
let options = {fixedColumns: true, columns: [[{field: 'name', operate: 'LIKE'}, {field: 'operate', class: 'actions', buttons: [1]}]]};
configure(options);
assert.strictEqual(options.fixedColumns, false);
assert.strictEqual(options.columns[0][1].class, 'actions yjyf-table-operate');
assert.strictEqual(options.columns[0][0].operate, 'LIKE');
assert.deepStrictEqual(options.columns[0][1].buttons, [1]);
let plain = {fixedColumns: true, columns: [[{field: 'name'}]]};
configure(plain);
assert.strictEqual(plain.fixedColumns, true);
configure(options);
assert.strictEqual(options.columns[0][1].class, 'actions yjyf-table-operate');
console.log('admin table layout behavior passed');

110
tests/master_hall_filters.js 普通文件
查看文件

@@ -0,0 +1,110 @@
const http = require('http');
const assert = require('assert').strict;
const { execFileSync } = require('child_process');
const base = process.env.API_BASE || 'http://yjyf:9560/api';
function request(path, method = 'GET', data = '', token = '') {
return new Promise((resolve, reject) => {
const url = new URL(base + path);
const headers = token ? { token } : {};
if (data) headers['content-type'] = 'application/x-www-form-urlencoded';
const req = http.request(url, { method, headers }, res => {
let text = ''; res.on('data', c => text += c); res.on('end', () => {
try { resolve(JSON.parse(text)); } catch (e) { reject(new Error(text)); }
});
});
req.on('error', reject); if (data) req.write(data); req.end();
});
}
(async () => {
if (!process.env.HALL_TEST_MOBILE || !process.env.HALL_TEST_PASSWORD) throw new Error('请通过环境变量提供 HALL_TEST_MOBILE 和 HALL_TEST_PASSWORD');
const login = await request('/auth/login', 'POST', new URLSearchParams({ mobile: process.env.HALL_TEST_MOBILE, password: process.env.HALL_TEST_PASSWORD }).toString());
assert.equal(login.code, 1, login.msg);
const token = login.data.token;
const call = async (params) => {
const r = await request('/master/hall?' + new URLSearchParams(params), 'GET', '', token);
assert.equal(r.code, 1, r.msg); return r.data;
};
const initial = await call({ limit: 2, sort: 'new' });
assert.ok(Array.isArray(initial.filter_options.categories), '分类选项应来自接口');
assert.ok(Array.isArray(initial.filter_options.service_types), '服务类型选项应来自接口');
const baseline = await call({ limit: 1, sort: 'new' });
assert.equal(initial.total, baseline.total);
for (const [key, option, valueKey] of [['cat_id', initial.filter_options.categories[0], 'id'], ['service_type', initial.filter_options.service_types[0], 'code']]) {
if (!option) continue;
const params = { [key]: option[valueKey], limit: 1, sort: 'new' };
const first = await call(params);
assert.ok(first.total <= baseline.total, key + ' 不应增加总数');
assert.equal(first.has_more, first.total > 1);
const second = await call({ ...params, page: 2 });
assert.equal(second.total, first.total);
if (first.list.length && second.list.length) assert.notEqual(first.list[0].id, second.list[0].id);
}
const reset = await call({ limit: 1, sort: 'new' });
assert.equal(reset.total, baseline.total);
for (const filter of [{ distance_km: -1 }, { distance_km: 999 }, { service_type: 'invalid_type' }, { cat_id: 999999 }]) {
const rejected = await request('/master/hall?' + new URLSearchParams(filter), 'GET', '', token);
assert.notEqual(rejected.code, 1, 'invalid filter must be rejected: ' + JSON.stringify(filter));
}
const rows = [];
for (let page = 1; ; page++) {
const result = await call({ limit: 30, page, sort: 'new' });
rows.push(...result.list);
if (!result.has_more) break;
}
assert.equal(rows.length, baseline.total);
if (rows.length) {
const mysql = process.env.HALL_TEST_MYSQL || 'D:\\Softwares\\phpstudy_pro\\Extensions\\MySQL5.7.26\\bin\\mysql.exe';
const sql = 'SELECT id,cat_id,lat,lng,HEX(COALESCE(goods_images,\'\')) FROM fa_order WHERE id IN (' + rows.map(r => Number(r.id)).join(',') + ')';
const output = execFileSync(mysql, ['-h', '127.0.0.1', '-u', 'yjyf', '-D', 'yjyf', '--batch', '--skip-column-names', '--execute=' + sql], { encoding: 'utf8', env: process.env }).trim();
const dbRows = output.split(/\r?\n/).map(line => {
const [id, cat, lat, lng, hex] = line.split('\t');
let goods = {}; try { goods = JSON.parse(Buffer.from(hex || '', 'hex').toString('utf8')); } catch (_) {}
return { id: Number(id), cat: Number(cat), lat: Number(lat), lng: Number(lng), types: (goods.goods_list || []).map(item => item.service_type) };
});
const info = await request('/master/info', 'GET', '', token);
assert.equal(info.code, 1, info.msg);
const master = info.data.master;
const lat = Number(master.lat), lng = Number(master.lng);
const distanceKm = row => {
const rad = n => n * Math.PI / 180;
const c = Math.sin(rad(lat)) * Math.sin(rad(row.lat)) + Math.cos(rad(lat)) * Math.cos(rad(row.lat)) * Math.cos(rad(row.lng - lng));
return 6371 * Math.acos(Math.min(1, Math.max(-1, c)));
};
const category = initial.filter_options.categories.find(c => dbRows.some(r => r.cat === Number(c.id)));
const service = initial.filter_options.service_types.find(t => dbRows.some(r => r.types.includes(t.code)));
const cases = [];
if (category) cases.push({ cat_id: category.id });
if (service) cases.push({ service_type: service.code });
if (lat && lng) cases.push({ distance_km: 15 });
if (category && service && lat && lng) cases.push({ cat_id: category.id, service_type: service.code, distance_km: 15 });
for (const filter of cases) {
const expected = dbRows.filter(row => (!filter.cat_id || row.cat === Number(filter.cat_id)) && (!filter.service_type || row.types.includes(filter.service_type)) && (!filter.distance_km || ((row.lat || row.lng) && distanceKm(row) <= Number(filter.distance_km)))).map(r => r.id).sort((a,b) => a-b);
for (const sort of ['recommend', 'distance', 'new', 'amount', 'urgent']) {
const actual = [];
const actualRows = [];
let response;
for (let page = 1; ; page++) {
response = await call({ ...filter, sort, limit: 3, page });
actual.push(...response.list.map(r => Number(r.id)));
actualRows.push(...response.list);
assert.equal(response.total, expected.length, JSON.stringify({ filter, sort }));
if (!response.has_more) break;
}
assert.deepEqual(actual.sort((a,b) => a-b), expected, JSON.stringify({ filter, sort }));
for (let i = 1; i < actualRows.length; i++) {
if (sort === 'new') assert.ok(Number(actualRows[i - 1].id) > Number(actualRows[i].id));
if (sort === 'amount') assert.ok(Number(actualRows[i - 1].pay_amount) >= Number(actualRows[i].pay_amount));
if (sort === 'urgent') assert.ok(Number(actualRows[i - 1].urgent) >= Number(actualRows[i].urgent));
if (sort === 'distance' && filter.distance_km) assert.ok(Number(actualRows[i - 1].distance_km) <= Number(actualRows[i].distance_km));
}
assert.equal(response.counts.all, expected.length);
for (const type of ['fixed', 'quote', 'custom']) {
const typed = await call({ ...filter, sort, type, limit: 1 });
assert.equal(typed.total, response.counts[type], type + ' count');
}
}
}
console.log('verified real orders:', rows.length, 'filter combinations:', cases.length);
}
console.log('master hall filter API checks passed');
})().catch(e => { console.error(e.message); process.exitCode = 1; });

查看文件

@@ -0,0 +1,35 @@
import { strict as assert } from 'assert';
import fs from 'fs';
import vm from 'vm';
import { savePickedLocation } from '../yjyf-app/utils/masterHallLocation.mjs';
let payload;
const result = await savePickedLocation(
{ latitude: 26.57, longitude: 106.71, name: '测试地点', address: '测试地址' },
async (data) => { payload = data; return { location_city: '贵阳市', serve_radius: 20 }; }
);
assert.deepEqual(payload, { lat: 26.57, lng: 106.71, label: '测试地点' });
assert.equal(result.city, '贵阳市');
assert.equal(result.serveRadius, 20);
await assert.rejects(() => savePickedLocation({ latitude: 0, longitude: 0 }, async () => ({})));
await assert.rejects(() => savePickedLocation({ latitude: 26, longitude: 106 }, async () => { throw new Error('保存失败'); }), /保存失败/);
// Exercise the real cache code with a simulated uni storage boundary.
const storage = {};
const uni = {
getStorageSync: (key) => storage[key],
setStorageSync: (key, value) => { storage[key] = value; }
};
const source = fs.readFileSync(new URL('../yjyf-app/utils/location.js', import.meta.url), 'utf8')
.replace(/import \{ tiandituWebKey \} from [^;]+;/, "const tiandituWebKey = ''; ")
.replace(/export function /g, 'function ');
const context = vm.createContext({ uni, Date, Number, String, Math, Array, Boolean });
vm.runInContext(source, context);
context.saveManualLocation({ lat: 26.57, lng: 106.71, label: '测试地点', serveRadius: 20, manual: true });
storage.yjyf_master_manual_loc_v1.updatedAt = Date.now() - 2 * 86400000;
assert.equal(context.getSavedManualLocation().label, '测试地点');
assert.equal(context.getSavedManualLocation().manual, true);
context.saveManualLocation({ lat: 26.57, lng: 106.71 });
storage.yjyf_master_manual_loc_v1.updatedAt = Date.now() - 2 * 86400000;
assert.equal(context.getSavedManualLocation(), null);
console.log('master hall location tests passed');

查看文件

@@ -35,10 +35,9 @@
</view>
<view class="sort-bar">
<scroll-view class="sort-tabs-scroll" scroll-x="true" :show-scrollbar="false">
<view class="sort-tabs-inner">
<view class="sort-tabs-inner">
<view
v-for="s in sortTabs"
v-for="s in sortTabs.slice(0, 3)"
:key="s.key"
class="s-tab clickable-hover"
:class="{ on: sort === s.key }"
@@ -46,32 +45,26 @@
>
<text class="s-tab-txt">{{ s.name }}</text>
</view>
</view>
</scroll-view>
<view class="refresh-pill clickable-hover" @tap="manualRefresh">
<image
class="refresh-ico"
:class="{ spinning: loading }"
src="/static/icons/master/hall-refresh.svg"
mode="aspectFit"
/>
<text class="refresh-txt">刷新</text>
</view>
<view class="filter-trigger clickable-hover" :class="{ active: activeFilterChips.length }" @tap="openFilters">
<image class="filter-icon" src="/static/icons/filter-orange.svg" mode="aspectFit" />
<text>筛选{{ activeFilterChips.length ? '(' + activeFilterChips.length + ')' : '' }}</text>
</view>
</view>
<view class="active-filters" v-if="activeFilterChips.length">
<view class="active-filter" v-for="chip in activeFilterChips" :key="chip.key" @tap="clearFilter(chip.key)">
<text>{{ chip.label }}</text>
<image class="active-filter-close" src="/static/icons/close.svg" mode="aspectFit" />
</view>
<view class="clear-filters" @tap="clearAllFilters">清除</view>
</view>
</view>
<!-- 定位状态与接单区域快捷 bar(不遮挡,仅按需触发原生授权或区域校准) -->
<view
class="loc-status-bar clickable-hover"
:class="{ warn: !hasCoords && serverLocationSource === 'none' }"
@tap="handleLocationBarTap"
>
<view class="loc-bar-left">
<view class="loc-status-bar" :class="{ warn: !hasCoords && serverLocationSource === 'none' }">
<view class="loc-bar-left clickable-hover" @tap="handleLocationBarTap">
<image class="loc-bar-ico" src="/static/icons/master/hall-location-pin.svg" mode="aspectFit" />
<text class="loc-bar-txt">{{ locBarText }}</text>
</view>
<view class="loc-bar-action">
<text class="loc-bar-action-txt">{{ locBarActionText }}</text>
<image class="loc-bar-arrow" src="/static/icons/master/hall-arrow-right-orange.svg" mode="aspectFit" />
</view>
</view>
@@ -128,7 +121,7 @@
/>
<!-- 状态 2:异常错误重试态 -->
<view class="state-empty-wrap" v-else-if="loadError && !list.length">
<view class="state-empty-wrap" v-else-if="loadError">
<image class="state-img" src="/static/icons/master/hall-error.svg" mode="aspectFit" />
<text class="state-title">工单大厅加载失败</text>
<text class="state-sub">{{ loadError }}</text>
@@ -150,8 +143,8 @@
<view class="card-hd">
<view class="hd-left">
<text class="tag-urgent" v-if="Number(o.urgent)">急单</text>
<text class="tag-svc-type" :class="{ repair: o.service_type_tag === '维修' }">
{{ o.service_type_tag || '安装' }}
<text v-if="o.service_type_tag" class="tag-svc-type" :class="{ repair: o.service_type_tag === '维修' }">
{{ o.service_type_tag }}
</text>
<text class="svc-title">{{ o.service_name }}</text>
</view>
@@ -274,11 +267,12 @@
<view class="state-empty-wrap" v-else>
<image class="state-img" src="/static/icons/master/empty-orders.svg" mode="aspectFit" />
<text class="state-title">当前筛选下暂无待接工单</text>
<text class="state-sub">可尝试切换订单类型、刷新列表或扩展接单技能范围</text>
<text class="state-sub">{{ activeFilterChips.length ? '可清除筛选条件后查看其他订单' : '可尝试切换订单类型、刷新列表或扩展接单技能范围' }}</text>
<view class="state-actions">
<view class="cta-primary clickable-hover" v-if="activeFilterChips.length" @tap="clearAllFilters">清除筛选</view>
<view
class="cta-primary clickable-hover"
v-if="type !== 'all' && counts.all > 0"
v-else-if="type !== 'all' && counts.all > 0"
@tap="switchType('all')"
>
查看全部订单 ({{ formatCount(counts.all) }})
@@ -289,6 +283,37 @@
</view>
</YjyfRefreshScroll>
<view v-if="filtersOpen" class="filter-mask" @tap="filtersOpen = false">
<view class="filter-panel" @tap.stop>
<view class="filter-heading">
<text>订单筛选</text>
<view class="filter-close" @tap="filtersOpen = false"><image class="filter-close-icon" src="/static/icons/close.svg" mode="aspectFit" /></view>
</view>
<scroll-view class="filter-content" scroll-y>
<view class="filter-group">
<text class="filter-title">排序方式</text>
<view class="filter-options"><view v-for="item in sortTabs" :key="item.key" class="filter-option" :class="{ selected: draftSort === item.key }" @tap="draftSort = item.key">{{ item.name }}</view></view>
</view>
<view class="filter-group">
<text class="filter-title">订单距离</text>
<text class="filter-hint">只显示所选距离内的订单;与推荐范围分别设置</text>
<view class="filter-options"><view v-for="item in distanceOptions" :key="item.value" class="filter-option" :class="{ selected: draftDistance === item.value }" @tap="draftDistance = item.value">{{ item.label }}</view></view>
</view>
<view class="filter-group" v-if="filterOptions.service_types.length">
<text class="filter-title">服务类型</text>
<text class="filter-hint">根据订单中的服务明细筛选</text>
<view class="filter-options"><view class="filter-option" :class="{ selected: !draftServiceType }" @tap="draftServiceType = ''">全部</view><view v-for="item in visibleServiceTypes" :key="item.code" class="filter-option" :class="{ selected: draftServiceType === item.code }" @tap="draftServiceType = item.code">{{ item.name }}</view></view>
<view v-if="filterOptions.service_types.length > 5" class="filter-expand" @tap="showAllServiceTypes = !showAllServiceTypes">{{ showAllServiceTypes ? '收起服务类型' : '展开全部服务类型' }}</view>
</view>
<view class="filter-group" v-if="filterOptions.categories.length">
<text class="filter-title">服务品类</text>
<view class="filter-options"><view class="filter-option" :class="{ selected: !draftCategory }" @tap="draftCategory = 0">全部</view><view v-for="item in filterOptions.categories" :key="item.id" class="filter-option" :class="{ selected: draftCategory === Number(item.id) }" @tap="draftCategory = Number(item.id)">{{ item.name }}</view></view>
</view>
</scroll-view>
<view class="filter-footer"><view class="filter-reset" @tap="resetDraftFilters">重置</view><view class="filter-confirm" @tap="applyFilters">确定</view></view>
</view>
</view>
<!-- 4. 抢单防误点二次确认弹窗 -->
<view class="confirm-mask" v-if="selectedOrder" @tap="closeGrabConfirm">
<view class="confirm-dialog" @tap.stop>
@@ -323,12 +348,12 @@
import api from '@/utils/api.js';
import { isLogin, toLogin } from '@/utils/request.js';
import { setRole } from '@/utils/role.js';
import { savePickedLocation } from '@/utils/masterHallLocation.mjs';
import {
checkLocationPermissionStatus,
getCurrentCoordinates,
getSavedManualLocation,
saveManualLocation,
openMiniProgramLocationSettingSync
saveManualLocation
} from '@/utils/location.js';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
import YjyfRefreshScroll from '@/components/YjyfRefreshScroll.vue';
@@ -347,7 +372,6 @@
const locationStatus = ref('prompt');
const locationCity = ref('');
const locationLabel = ref('');
const serveRadius = ref(15);
const serverLocationSource = ref('none');
const requestingLocation = ref(false);
const initializingLocation = ref(false);
@@ -357,20 +381,26 @@
const locBarText = computed(() => {
if (hasCoords.value) {
const name = locationLabel.value || locationCity.value || '已开启实时定位';
return `当前位置:${name}(${serveRadius.value}km内)`;
return `接单位置:${name}`;
}
if (serverLocationSource.value === 'saved') {
return `已按历史位置(${locationCity.value || '常驻城市'} · ${serveRadius.value}km内)为您推荐`;
return `接单位置:${locationCity.value || '已保存位置'}`;
}
return '未获取当前位置,开启或设置位置后可精准推荐附近订单';
});
const locBarActionText = computed(() => {
if (hasCoords.value) return '切换位置';
if (serverLocationSource.value === 'saved') return '设置位置';
return '选择位置';
return '选择接单位置';
});
const type = ref('all');
const sort = ref('recommend');
const filterOptions = ref({ categories: [], service_types: [] });
const distance = ref(0);
const category = ref(0);
const serviceType = ref('');
const filtersOpen = ref(false);
const draftSort = ref('recommend');
const draftDistance = ref(0);
const draftCategory = ref(0);
const draftServiceType = ref('');
const showAllServiceTypes = ref(false);
const visibleServiceTypes = computed(() => showAllServiceTypes.value ? filterOptions.value.service_types : filterOptions.value.service_types.slice(0, 5));
const selectedOrder = ref(null);
const grabbing = ref(false);
const togglingWork = ref(false);
@@ -390,9 +420,27 @@
{ key: 'recommend', name: '智能推荐' },
{ key: 'distance', name: '离我最近' },
{ key: 'new', name: '最新发布' },
{ key: 'amount', name: '报酬最高' },
{ key: 'amount', name: '实付最高' },
{ key: 'urgent', name: '急单优先' }
];
const distanceOptions = [
{ value: 0, label: '不限' }, { value: 5, label: '5km内' },
{ value: 15, label: '15km内' }, { value: 30, label: '30km内' }, { value: 50, label: '50km内' }
];
const activeFilterChips = computed(() => {
const chips = [];
if (sort.value === 'amount' || sort.value === 'urgent') chips.push({ key: 'sort', label: sortTabs.find(s => s.key === sort.value).name });
if (distance.value) chips.push({ key: 'distance', label: `${distance.value}km内` });
if (serviceType.value) {
const item = filterOptions.value.service_types.find(s => s.code === serviceType.value);
if (item) chips.push({ key: 'serviceType', label: item.name });
}
if (category.value) {
const item = filterOptions.value.categories.find(c => Number(c.id) === category.value);
if (item) chips.push({ key: 'category', label: item.name });
}
return chips;
});
// 基于真实待接工单生成可点击直达详情的实时广播条
const broadcastList = computed(() => {
@@ -438,9 +486,50 @@
if (locationCity.value) {
params.city = locationCity.value;
}
if (distance.value) params.distance_km = distance.value;
if (category.value) params.cat_id = category.value;
if (serviceType.value) params.service_type = serviceType.value;
return params;
}
function openFilters() {
draftSort.value = sort.value;
draftDistance.value = distance.value;
draftCategory.value = category.value;
draftServiceType.value = serviceType.value;
showAllServiceTypes.value = Boolean(serviceType.value && !filterOptions.value.service_types.slice(0, 5).some(item => item.code === serviceType.value));
filtersOpen.value = true;
}
function resetDraftFilters() {
draftSort.value = 'recommend';
draftDistance.value = 0;
draftCategory.value = 0;
draftServiceType.value = '';
}
function applyFilters() {
if ((draftDistance.value || draftSort.value === 'distance') && !hasCoords.value && serverLocationSource.value === 'none') {
uni.showToast({ title: '请先选择接单位置', icon: 'none' });
return;
}
sort.value = draftSort.value;
distance.value = draftDistance.value;
category.value = draftCategory.value;
serviceType.value = draftServiceType.value;
filtersOpen.value = false;
fetchHallList();
}
function clearFilter(key) {
if (key === 'sort') sort.value = 'recommend';
if (key === 'distance') distance.value = 0;
if (key === 'category') category.value = 0;
if (key === 'serviceType') serviceType.value = '';
fetchHallList();
}
function clearAllFilters() {
sort.value = 'recommend'; distance.value = 0; category.value = 0; serviceType.value = '';
fetchHallList();
}
function switchType(k) {
if (type.value === k) return;
type.value = k;
@@ -449,7 +538,8 @@
function switchSort(k) {
if (k === 'distance' && !hasCoords.value && serverLocationSource.value === 'none') {
handleRequestLocation();
handleLocationBarTap();
return;
}
if (sort.value === k) return;
sort.value = k;
@@ -539,106 +629,49 @@
}
}
function openLocationPage() {
const query = [];
if (coords.value.lat && coords.value.lng) {
query.push(`lat=${encodeURIComponent(coords.value.lat)}`);
query.push(`lng=${encodeURIComponent(coords.value.lng)}`);
}
if (locationCity.value) {
query.push(`city=${encodeURIComponent(locationCity.value)}`);
}
if (locationLabel.value) {
query.push(`label=${encodeURIComponent(locationLabel.value)}`);
}
if (serveRadius.value) {
query.push(`radius=${encodeURIComponent(serveRadius.value)}`);
}
const qs = query.length ? `?${query.join('&')}` : '';
uni.navigateTo({ url: `/pages/master/location${qs}` });
}
function handleLocationBarTap() {
if (hasCoords.value) {
openLocationPage();
return;
}
handleRequestLocation();
}
function handleRequestLocation() {
// #ifdef MP-WEIXIN
// 已被微信拒绝过权限时,必须在点击同步手势周期内直接唤起微信原生设置页
if (locationStatus.value === 'denied') {
requestingLocation.value = true;
openMiniProgramLocationSettingSync().then(async (res) => {
requestingLocation.value = false;
if (res && res.ok && res.lat && res.lng) {
locationStatus.value = 'granted';
await applyVerifiedLocation(res.lat, res.lng);
uni.showToast({ title: '定位已开启,已更新附近推荐', icon: 'none' });
} else {
openLocationPage();
}
});
return;
}
requestDeviceLocationInteractive();
return;
// #endif
// #ifndef MP-WEIXIN
openLocationPage();
// #endif
}
async function applyVerifiedLocation(lat, lng, customLabel = '', customCity = '') {
coords.value = { lat, lng };
if (customCity) locationCity.value = customCity;
if (customLabel) locationLabel.value = customLabel;
const res = await syncMasterLocation(lat, lng, customCity, customLabel);
const finalCity = customCity || (res && res.location_city) || locationCity.value || '';
const finalLabel = customLabel || (res && res.location_label) || finalCity || '已定位';
const finalRadius = (res && res.serve_radius) || serveRadius.value;
locationCity.value = finalCity;
locationLabel.value = finalLabel;
serveRadius.value = finalRadius;
saveManualLocation({ lat, lng, label: finalLabel, city: finalCity, serveRadius: finalRadius });
await fetchHallList();
}
async function requestDeviceLocationInteractive() {
if (requestingLocation.value) return;
if (requestingLocation.value || initializingLocation.value) return;
requestingLocation.value = true;
try {
const res = await getCurrentCoordinates({ timeout: 4500 });
if (res && res.ok && res.lat && res.lng) {
locationStatus.value = 'granted';
await applyVerifiedLocation(res.lat, res.lng);
uni.showToast({ title: '定位成功,已为您推荐附近工单', icon: 'none' });
} else {
if (res && res.reason === 'denied') {
locationStatus.value = 'denied';
const options = {
success: async (selection) => {
try {
++loadSeq;
const saved = await savePickedLocation(selection, api.masterUpdateLocation);
coords.value = { lat: saved.lat, lng: saved.lng };
locationCity.value = saved.city;
locationLabel.value = saved.label;
saveManualLocation({ ...saved, manual: true });
await fetchHallList();
uni.showToast({ title: '接单位置已更新', icon: 'none' });
} catch (e) {
loading.value = false;
uni.showToast({ title: e?.msg || e?.message || '保存位置失败,请重试', icon: 'none' });
} finally {
requestingLocation.value = false;
}
},
fail: (err) => {
requestingLocation.value = false;
if (!String(err?.errMsg || '').toLowerCase().includes('cancel')) {
uni.showToast({ title: '无法打开位置选择,请检查定位权限', icon: 'none' });
}
openLocationPage();
}
} finally {
requestingLocation.value = false;
};
if (hasCoords.value) {
options.latitude = Number(coords.value.lat);
options.longitude = Number(coords.value.lng);
}
}
function onLocationPageUpdated(payload) {
if (!payload) return;
if (payload.lat && payload.lng) {
coords.value = { lat: payload.lat, lng: payload.lng };
}
if (payload.city) locationCity.value = payload.city;
if (payload.label) locationLabel.value = payload.label;
if (payload.serveRadius) serveRadius.value = Number(payload.serveRadius) || serveRadius.value;
fetchHallList();
uni.chooseLocation(options);
}
async function resolveLocationSilent(timeoutMs = 3500) {
const saved = getSavedManualLocation();
if (saved && saved.manual) {
coords.value = { lat: saved.lat, lng: saved.lng };
locationCity.value = saved.city;
locationLabel.value = saved.label;
return true;
}
const status = await checkLocationPermissionStatus();
locationStatus.value = status;
@@ -675,7 +708,6 @@
}
// 若实时设备定位未获取,回读近期手动校准过的真实地点缓存
const saved = getSavedManualLocation();
if (saved) {
coords.value = { lat: saved.lat, lng: saved.lng };
if (saved.city) locationCity.value = saved.city;
@@ -704,7 +736,7 @@
toLogin('/pages/master/hall');
return;
}
if (initializingLocation.value) {
if (initializingLocation.value || requestingLocation.value) {
return;
}
const saved = getSavedManualLocation();
@@ -712,7 +744,6 @@
coords.value = { lat: saved.lat, lng: saved.lng };
if (saved.city) locationCity.value = saved.city;
if (saved.label) locationLabel.value = saved.label;
if (saved.serveRadius) serveRadius.value = saved.serveRadius;
} else if (!hasCoords.value) {
await resolveLocationSilent(3000);
}
@@ -760,12 +791,10 @@
if (hallRes.counts) {
counts.value = hallRes.counts;
}
if (hallRes.filter_options) filterOptions.value = hallRes.filter_options;
if (hallRes.location_city) {
locationCity.value = hallRes.location_city;
}
if (hallRes.serve_radius) {
serveRadius.value = Number(hallRes.serve_radius) || serveRadius.value;
}
serverLocationSource.value = hallRes.location_source || 'none';
} else if (hallResult.status === 'rejected') {
const err = hallResult.reason;
@@ -845,12 +874,10 @@
}
onMounted(() => {
uni.$on('masterLocationUpdated', onLocationPageUpdated);
initLocationAndLoad();
});
onBeforeUnmount(() => {
uni.$off('masterLocationUpdated', onLocationPageUpdated);
while (timers.length) {
clearTimeout(timers.pop());
}
@@ -1674,11 +1701,37 @@
}
}
.sort-tabs-inner {
display: inline-flex;
display: flex;
flex: 1;
min-width: 0;
align-items: center;
gap: 10rpx;
gap: 6rpx;
padding-right: $yjyf-space-xs;
}
.sort-tabs-inner .s-tab { flex: 1; min-width: 0; padding: 0 8rpx; }
.filter-trigger { flex-shrink: 0; min-height: 88rpx; display: flex; align-items: center; gap: 6rpx; color: $yjyf-primary; font-size: $yjyf-font-sub; font-weight: 600; }
.filter-icon { width: 26rpx; height: 26rpx; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8rpx; padding: 0 $yjyf-space-md $yjyf-space-sm; }
.active-filter { display: inline-flex; align-items: center; gap: 6rpx; min-height: 52rpx; padding: 0 16rpx; border-radius: $yjyf-radius-pill; background: $yjyf-primary-bg; color: $yjyf-primary; font-size: $yjyf-font-micro; }
.active-filter-close { width: 18rpx; height: 18rpx; }
.clear-filters { display: flex; align-items: center; min-height: 52rpx; padding: 0 12rpx; color: $yjyf-text-secondary; font-size: $yjyf-font-sub; }
.filter-mask { position: fixed; inset: 0; z-index: 1005; background: rgba(0, 0, 0, 0.48); display: flex; align-items: flex-end; }
.filter-panel { width: 100%; height: 78vh; display: flex; flex-direction: column; background: $yjyf-bg-card; border-radius: $yjyf-radius-lg $yjyf-radius-lg 0 0; overflow: hidden; }
.filter-heading { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 $yjyf-space-md; height: 96rpx; font-size: 32rpx; font-weight: 700; color: $yjyf-text-main; border-bottom: 1rpx solid $yjyf-border-color; }
.filter-close { width: 88rpx; height: 88rpx; display: flex; align-items: center; justify-content: center; }
.filter-close-icon { width: 28rpx; height: 28rpx; }
.filter-content { flex: 1; min-height: 0; height: 0; box-sizing: border-box; padding: 0 $yjyf-space-md; }
.filter-group { padding: 24rpx 0; border-bottom: 1rpx solid $yjyf-border-color; }
.filter-title { display: block; color: $yjyf-text-main; font-size: $yjyf-font-body; font-weight: 700; }
.filter-hint { display: block; margin-top: 8rpx; color: $yjyf-text-secondary; font-size: $yjyf-font-micro; line-height: 1.4; }
.filter-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12rpx; margin-top: 16rpx; }
.filter-option { min-height: 76rpx; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8rpx; box-sizing: border-box; border-radius: $yjyf-radius-sm; border: 1rpx solid transparent; background: $yjyf-bg-page; color: $yjyf-text-regular; font-size: $yjyf-font-sub; }
.filter-option.selected { color: $yjyf-primary; border-color: $yjyf-primary; background: $yjyf-primary-bg; font-weight: 600; }
.filter-expand { display: flex; align-items: center; min-height: 72rpx; color: $yjyf-primary; font-size: $yjyf-font-sub; }
.filter-footer { flex-shrink: 0; display: flex; gap: 16rpx; padding: 16rpx $yjyf-space-md calc(16rpx + env(safe-area-inset-bottom)); border-top: 1rpx solid $yjyf-border-color; background: $yjyf-bg-card; }
.filter-reset, .filter-confirm { flex: 1; height: 80rpx; display: flex; align-items: center; justify-content: center; border-radius: $yjyf-radius-pill; font-size: $yjyf-font-body; font-weight: 600; }
.filter-reset { background: $yjyf-bg-page; color: $yjyf-text-regular; }
.filter-confirm { background: $yjyf-gradient-primary; color: $yjyf-text-inverse; }
/* 位置状态与引导条(紧贴控制台下方,不阻挡主列表) */
.loc-status-bar {
@@ -1697,6 +1750,7 @@
.loc-bar-left {
flex: 1;
min-width: 0;
min-height: 88rpx;
display: flex;
align-items: center;
gap: 10rpx;
@@ -1719,18 +1773,6 @@
.loc-status-bar.warn .loc-bar-txt {
color: $yjyf-text-regular;
}
.loc-bar-action {
flex-shrink: 0;
display: inline-flex;
align-items: center;
padding: 4rpx 0;
}
.loc-bar-action-txt {
font-size: $yjyf-font-sub;
font-weight: 600;
color: $yjyf-primary;
line-height: 1;
}
.loc-bar-arrow {
width: 22rpx;
height: 22rpx;

查看文件

@@ -28,7 +28,7 @@ export function getSavedManualLocation() {
if (!Number.isFinite(lat) || !Number.isFinite(lng) || (Math.abs(lat) < 0.0001 && Math.abs(lng) < 0.0001)) {
return null;
}
if (updatedAt > 0 && Date.now() - updatedAt > MANUAL_LOC_TTL_MS) {
if (!raw.manual && updatedAt > 0 && Date.now() - updatedAt > MANUAL_LOC_TTL_MS) {
return null;
}
return {
@@ -38,6 +38,7 @@ export function getSavedManualLocation() {
city: String(raw.city || ''),
district: String(raw.district || ''),
serveRadius: Number(raw.serveRadius) || 0,
manual: Boolean(raw.manual),
updatedAt
};
} catch (e) {
@@ -48,7 +49,7 @@ export function getSavedManualLocation() {
/**
* 保存用户主动定位或选定的真实经纬度坐标
*/
export function saveManualLocation({ lat, lng, label = '', city = '', district = '', serveRadius = 0 }) {
export function saveManualLocation({ lat, lng, label = '', city = '', district = '', serveRadius = 0, manual = false }) {
const latNum = Number(lat);
const lngNum = Number(lng);
if (!Number.isFinite(latNum) || !Number.isFinite(lngNum)) return;
@@ -60,6 +61,7 @@ export function saveManualLocation({ lat, lng, label = '', city = '', district =
city: String(city || ''),
district: String(district || ''),
serveRadius: Number(serveRadius) || 0,
manual: Boolean(manual),
updatedAt: Date.now()
});
} catch (e) {}

查看文件

@@ -0,0 +1,17 @@
export async function savePickedLocation(selection, updateLocation) {
const lat = Number(selection?.latitude);
const lng = Number(selection?.longitude);
if (!Number.isFinite(lat) || !Number.isFinite(lng) || Math.abs(lat) > 90 || Math.abs(lng) > 180 || (!lat && !lng)) {
throw new Error('所选位置坐标无效,请重新选择');
}
const label = selection.name || selection.address || '';
const result = await updateLocation({ lat, lng, label });
return {
lat,
lng,
label: label || result?.location_label || '',
city: result?.location_city || '',
district: result?.location_district || '',
serveRadius: Number(result?.serve_radius) || 0
};
}