订单完善

This commit is contained in:
邓皓元 2019-03-15 11:08:35 +08:00
parent d2f53423ad
commit 97cc55fc91
28 changed files with 376 additions and 356 deletions

View File

@ -78,7 +78,25 @@ class AddedOrderSync extends Command
foreach ($dataOrderCards as $type => $orderCards) {
foreach (array_chunk($orderCards, $this->chunks) as $data) {
$this->getOutput()->write('.');
DB::table($this->tables[$type])->upsert($data, ['sim', 'order_id']);
$table = $this->tables[$type];
$virtualTable = str_replace('real_', 'virtual_', $table);
$starttime = $this->datetime->copy()->startOfMonth()->startOfDay();
$endtime = $this->datetime->copy()->endOfMonth()->endOfDay();
$orders = DB::table($virtualTable)->selectRaw('sim,MAX(order_id)')
->where('create_time', '>=', $starttime->timestamp)
->where('create_time', '<=', $endtime->timestamp)
->whereIn('sim', array_pluck($data, 'sim'))
->groupBy('sim')->get()->pluck('order_id', 'sim');
foreach ($data as &$value) {
$value['virtual_order_id'] = $orders[$value['sim']] ?? 0;
}
DB::table($table)->upsert($data, ['sim', 'order_id'], true);
}
}

View File

@ -46,7 +46,13 @@ class OrderBaseSync extends Command
$this->line('插入订单关联数据,条数:'.count($cards));
foreach (array_chunk($cards, $this->chunks) as $data) {
$this->getOutput()->write('.');
DB::table('real_order_cards')->upsert($data, ['sim', 'deleted_at']);
$orders = DB::table('virtual_order_cards')->select(['sim', 'order_id'])->whereIn('sim', array_pluck($data, 'sim'))->get()->pluck('order_id', 'sim');
foreach ($data as &$value) {
$value['virtual_order_id'] = $orders[$value['sim']] ?? 0;
}
DB::table('real_order_cards')->upsert($data, ['sim', 'deleted_at'], true);
}
app(OrderCardPartitionRepository::class)->forgetCached();
$this->line('插入订单关联数据成功');

View File

@ -51,7 +51,7 @@ class OrderCardPartitionRepository extends Repository
public function withVirtual($conditions)
{
$select = 'distinct on (real_order_cards_partition.sim)
$select = 'distinct on (real_order_cards_partition.id)
real_order_cards_partition.sim,
real_order_cards_partition.order_id,
real_order_cards_partition.virtual_order_id,
@ -64,13 +64,20 @@ class OrderCardPartitionRepository extends Repository
$this->model = $this->model->leftJoin('virtual_order_cards_partition', 'virtual_order_cards_partition.sim', '=', 'real_order_cards_partition.sim');
$this->model= $this->model->orderBy('real_order_cards_partition.sim')->orderBy('virtual_order_cards_partition.created_at');
$this->model= $this->model
->orderBy('real_order_cards_partition.id')
->orderBy('virtual_order_cards_partition.created_at');
if (isset($conditions['type'])) {
$conditions['type'] = array_wrap($conditions['type']);
$this->model= $this->model->whereIn('real_order_cards_partition.type', $conditions['type']);
}
if (isset($conditions['sim'])) {
$conditions['sim'] = array_wrap($conditions['sim']);
$this->model= $this->model->whereIn('real_order_cards_partition.sim', $conditions['sim']);
}
if (isset($conditions['order_id'])) {
$conditions['order_id'] = array_wrap($conditions['order_id']);
$this->model= $this->model->whereIn('real_order_cards_partition.order_id', $conditions['order_id']);

View File

@ -9,6 +9,7 @@ use App\Domains\Real\Repositories\OrderRepository;
use App\Domains\Real\Repositories\OrderCardPartitionRepository;
use App\Domains\Virtual\Repositories\OrderRepository as VirtualOrderRepository;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository as VirtualOrderCardPartitionRepository;
use App\Exceptions\NotAllowedException;
class OrderService extends Service
{
@ -72,6 +73,12 @@ class OrderService extends Service
ini_set('memory_limit', '4096m');
ini_set('default_socket_timeout', -1);
$counts = $this->orderCardPartitionRepository->withConditions($conditions)->count();
if ($counts > 100000) {
throw new NotAllowedException("当前请求总卡量为{$counts}张,数据量过大,请筛选过滤后查询");
}
$cards = $this->orderCardPartitionRepository->withVirtual($conditions)->get();
$tmpCards = $cards->groupBy('virtual_order_id');

View File

@ -21,6 +21,7 @@ use App\Models\Real\OrderCardPartition as RealOrderCardPartition;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
use App\Domains\Real\Repositories\OrderRepository as RealOrderRepository;
use App\Domains\Real\Repositories\OrderCardPartitionRepository as RealOrderCardPartitionRepository;
use App\Exceptions\InvalidArgumentException;
class OrderService extends Service
{
@ -109,7 +110,8 @@ class OrderService extends Service
public function store(array $attributes = [])
{
$rule = [
'type' => ['in:0,1,2,3,-1,-2'], // 转销售 -1改企业 -2
'type' => ['in:0,1,2,3'],
'sign' => ['in:1,2'], // 转销售 1改企业 2
'company_id' => ['exists:virtual_companies,id'],
'product_id' => [],
'counts' => [],
@ -165,9 +167,14 @@ class OrderService extends Service
DB::beginTransaction();
// 改企业的卡新增一批虚拟卡,并替换原有订单里的卡
if ($attributes['type'] == -2 && $attributes['selected']) {
if (isset($attributes['sign']) && $attributes['sign'] == 2) {
if (empty($attributes['selected'])) {
throw new InvalidArgumentException('请选择卡');
}
// 改企业的卡新增一批虚拟卡,并替换原有订单里的卡
$simArray = implode(',', array_pluck($attributes['selected'], 'sim'));
try {
DB::statement("select change_cards('{{$simArray}}'::INT8[]);");
} catch (\Exception $e) {
@ -176,8 +183,8 @@ class OrderService extends Service
}
}
// 转销售和企业的都立即激活卡
if ($attributes['type'] <0 && $attributes['selected']) {
// 转销售和企业的都立即激活卡
if (isset($attributes['sign']) && in_array($attributes['sign'], [1, 2])) {
$params = array_pluck($attributes['selected'], 'sim');
$sql = 'UPDATE cards SET virtual_activated_at = ? WHERE sim IN (%s)';
$sql = sprintf($sql, app(Grammar::class)->parameterize($params));
@ -317,25 +324,22 @@ class OrderService extends Service
*
* @return bool
*/
public function reset($ids)
public function reset($id)
{
$ids = is_array($ids) ? $ids : [$ids];
foreach ($ids as $id) {
if (!$node = $this->orderRepository->find($id)) {
throw new NotExistException('订单不存在或已删除');
}
if (!$node = $this->orderRepository->find($id)) {
throw new NotExistException('订单不存在或已删除');
}
DB::transaction(function () use ($ids) {
$sql = 'UPDATE virtual_order_cards_partition SET sim=original_sim,original_sim=0
WHERE original_sim IN (
SELECT DISTINCT SIM FROM virtual_order_cards_partition WHERE "type"=0 AND order_id IN (%s)
)';
DB::transaction(function () use ($id, $node) {
if ($node->type === 0) {
// 转销售重置
$sql = 'UPDATE virtual_order_cards_partition SET sim=original_sim,original_sim=0
WHERE original_sim IN (
SELECT DISTINCT SIM FROM virtual_order_cards_partition WHERE type=0 AND order_id = ?
)';
DB::statement($sql, $id);
}
$sql = sprintf($sql, app(Grammar::class)->parameterize($ids));
DB::statement($sql, $ids);
$this->orderCardPartitionRepository->whereIn('order_id', $ids)->delete();
app(RealOrderCardPartitionRepository::class)->whereIn('virtual_order_id', $ids)->update(['virtual_order_id' => 0]);
@ -364,15 +368,6 @@ class OrderService extends Service
$this->orderRepository->destroy($ids);
// DB::transaction(function () use ($ids) {
// $this->orderRepository->destroy($ids);
// $this->orderCardPartitionRepository->whereIn('order_id', $ids)->delete();
// app(RealOrderCardPartitionRepository::class)->whereIn('virtual_order_id', $ids)->update(['virtual_order_id' => 0]);
// });
// app(RealOrderCardPartitionRepository::class)->forgetCached();
// app(RealOrderRepository::class)->forgetCached();
return true;
}

View File

@ -43,6 +43,7 @@ class CreateVirtualOrdersTable extends Migration
$table->text('logistics_remark')->nullable()->comment('物流备注');
$table->text('remark')->nullable()->comment('订单备注');
$table->text('extends')->nullable()->comment('扩展信息(cancel_remark:取消备注 refund_channel:退款频道 refund_account:退款账号 refund_remark:退款备注)');
$table->tinyInteger('sign')->unsigned()->default(0)->comment('特殊标记 0:非特殊 -1:不在VD上的改企业转销售 -2改企业的转销售');
$table->timestamps();
$table->softDeletes();

View File

@ -132,6 +132,7 @@ export default {
} else {
this.renderType = "normal";
}
console.log(6);
}
};
</script>

View File

@ -6,38 +6,36 @@
<tbody :class="[prefixCls + '-tbody']">
<div :style="{height: `${topPlaceholderHeight}px`}"></div>
<template v-for="(table, i) in showData">
<template v-for="(row, index) in table">
<table-tr
:row="row"
:key="row._rowKey"
:prefix-cls="prefixCls"
@mouseenter.native.stop="handleMouseIn(row._index)"
@mouseleave.native.stop="handleMouseOut(row._index)"
@click.native="clickCurrentRow(row._index)"
@dblclick.native.stop="dblclickCurrentRow(row._index)"
>
<td v-for="column in columns" :class="alignCls(column, row)">
<Cell
:fixed="fixed"
:prefix-cls="prefixCls"
:row="row"
:key="column._columnKey"
:column="column"
:natural-index="index"
:index="row._index"
:checked="rowChecked(row._index)"
:disabled="rowDisabled(row._index)"
:expanded="rowExpanded(row._index)"
></Cell>
</td>
</table-tr>
<tr v-if="rowExpanded(row._index)" :class="{[prefixCls + '-expanded-hidden']: fixed}">
<td :colspan="columns.length" :class="prefixCls + '-expanded-cell'">
<Expand :key="row._rowKey" :row="row" :render="expandRender" :index="row._index"></Expand>
</td>
</tr>
</template>
<template v-for="(row, index) in data">
<table-tr
:row="row"
:key="row._rowKey"
:prefix-cls="prefixCls"
@mouseenter.native.stop="handleMouseIn(row._index)"
@mouseleave.native.stop="handleMouseOut(row._index)"
@click.native="clickCurrentRow(row._index)"
@dblclick.native.stop="dblclickCurrentRow(row._index)"
>
<td v-for="column in columns" :class="alignCls(column, row)">
<Cell
:fixed="fixed"
:prefix-cls="prefixCls"
:row="row"
:key="column._columnKey"
:column="column"
:natural-index="index"
:index="row._index"
:checked="rowChecked(row._index)"
:disabled="rowDisabled(row._index)"
:expanded="rowExpanded(row._index)"
></Cell>
</td>
</table-tr>
<tr v-if="rowExpanded(row._index)" :class="{[prefixCls + '-expanded-hidden']: fixed}">
<td :colspan="columns.length" :class="prefixCls + '-expanded-cell'">
<Expand :key="row._rowKey" :row="row" :render="expandRender" :index="row._index"></Expand>
</td>
</tr>
</template>
<div :style="{height: `${bottomPlaceholderHeight}px`}"></div>
</tbody>
@ -65,68 +63,10 @@ export default {
type: [Boolean, String],
default: false
},
scrollToRowIndex: {
type: Number,
default: 0
}
},
data() {
return {
times0: 0, //
times1: 0,
times2: -1,
placeholderHeight: 0, // ( + )
topPlaceholderHeight: 0, //
bottomPlaceholderHeight: 0, //
currentIndex: -1, //
showData: []
};
},
watch: {
data: {
handler() {
this.clear();
this.$nextTick(() => {
this.handleStyle();
});
}
},
scrollTop: {
handler() {
this.$nextTick(() => {
this.handleStyle();
});
}
},
currentIndex: {
handler() {
this.setTopPlace();
}
},
scrollToRowIndex: {
handler() {}
}
topPlaceholderHeight: Number,
bottomPlaceholderHeight: Number
},
computed: {
scrollTop() {
return this.$parent.scrollTop;
},
bodyHeight() {
return this.$parent.bodyHeight; //
},
rowHeight() {
let height = { small: 40, large: 60, default: 48 };
return height[this.$parent.size]; //
},
showRowNum() {
return parseInt(this.bodyHeight / this.rowHeight) + 5; //
},
moduleHeight() {
return this.showRowNum * this.rowHeight; //
},
totalRowHeight() {
return this.data.length * this.rowHeight; //
},
expandRender() {
let render = function() {
return "";
@ -161,83 +101,6 @@ export default {
},
dblclickCurrentRow(_index) {
this.$parent.dblclickCurrentRow(_index);
},
handleStyle() {
this.placeholderHeight = this.totalRowHeight - this.moduleHeight * 3; // ( + )
this.topPlaceholderHeight =
parseInt(this.scrollTop / this.moduleHeight) * this.moduleHeight;
this.bottomPlaceholderHeight =
this.placeholderHeight - this.topPlaceholderHeight < 0
? 0
: this.placeholderHeight - this.topPlaceholderHeight;
this.currentIndex = parseInt(
(this.scrollTop % (this.moduleHeight * 3)) / this.moduleHeight
);
},
clear() {
this.showData = [];
this.currentIndex = -1;
this.placeholderHeight = 0;
this.topPlaceholderHeight = 0;
this.bottomPlaceholderHeight = 0;
},
setTopPlace() {
let scrollTop = this.scrollTop;
let t0 = 0;
let t1 = 0;
let t2 = 0;
if (scrollTop > this.moduleHeight) {
switch (this.currentIndex) {
case 0:
t0 = parseInt(scrollTop / (this.moduleHeight * 3));
t1 = t2 = t0;
break;
case 1:
t1 = parseInt(
(scrollTop - this.moduleHeight) / (this.moduleHeight * 3)
);
t0 = t1 + 1;
t2 = t1;
break;
case 2:
t2 = parseInt(
(scrollTop - this.moduleHeight * 2) / (this.moduleHeight * 3)
);
t0 = t1 = t2 + 1;
}
}
this.times0 = t0;
this.times1 = t1;
this.times2 = t2;
this.setTableData();
},
setTableData() {
let count1 = this.times0 * this.showRowNum * 3;
let table1 = this.data.slice(count1, count1 + this.showRowNum);
let count2 = this.times1 * this.showRowNum * 3;
let table2 = this.data.slice(
count2 + this.showRowNum,
count2 + this.showRowNum * 2
);
let count3 = this.times2 * this.showRowNum * 3;
let table3 = this.data.slice(
count3 + this.showRowNum * 2,
count3 + this.showRowNum * 3
);
switch (this.currentIndex) {
case 0:
this.showData = [table1, table2, table3];
break;
case 1:
this.showData = [table2, table3, table1];
break;
case 2:
this.showData = [table3, table1, table2];
}
}
}
};

View File

@ -35,6 +35,8 @@
:data="rebuildData"
:columns-width="columnsWidth"
:obj-data="objData"
:topPlaceholderHeight="topPlaceholderHeight"
:bottomPlaceholderHeight="bottomPlaceholderHeight"
></table-body>
</div>
<div
@ -250,8 +252,16 @@ export default {
showHorizontalScrollBar: false,
headerWidth: 0,
headerHeight: 0,
showData: [],
scrollTop: 0,
scrollToRowIndex: -1 //
scrollToRowIndex: -1, // ,
times0: 0, //
times1: 0,
times2: -1,
placeholderHeight: 0, // ( + )
topPlaceholderHeight: 0, //
bottomPlaceholderHeight: 0, //
currentIndex: -1 //
};
},
computed: {
@ -398,11 +408,20 @@ export default {
rowHeight() {
let height = { small: 40, large: 60, default: 48 };
return height[this.size]; //
},
showRowNum() {
return parseInt(this.bodyHeight / this.rowHeight) - 5; //
},
moduleHeight() {
return this.showRowNum * this.rowHeight; //
},
totalRowHeight() {
return this.data.length * this.rowHeight; //
}
},
methods: {
rowClsName(index) {
return this.rowClassName(this.data[index], index);
return this.rowClassName(this.rebuildData[index], index);
},
handleResize() {
//let tableWidth = parseInt(getStyle(this.$el, 'width')) - 1;
@ -569,7 +588,7 @@ export default {
}
return JSON.parse(
JSON.stringify(
this.data.filter(
this.rebuildData.filter(
(data, index) => selectionIndexes.indexOf(index) > -1
)
)
@ -592,7 +611,7 @@ export default {
this.$emit(
status ? "on-select" : "on-select-cancel",
selection,
JSON.parse(JSON.stringify(this.data[_index]))
JSON.parse(JSON.stringify(this.rebuildData[_index]))
);
this.$emit("on-selection-change", selection);
},
@ -711,6 +730,7 @@ export default {
this.hideColumnFilter();
this.scrollTop = event.target.scrollTop;
this.rebuildData = this.makeData();
},
handleFixedMousewheel(event) {
let deltaY = event.deltaY;
@ -872,12 +892,15 @@ export default {
this.$emit("on-filter-change", this.cloneColumns[index]);
},
makeData() {
this.handleStyle();
let data = deepCopy(this.data);
data.forEach((row, index) => {
row._index = index;
row._rowKey = rowKey++;
});
return data;
return this.setScrollData(data);
},
makeDataWithSort() {
let data = this.makeData();
@ -909,7 +932,9 @@ export default {
},
makeObjData() {
let data = {};
this.data.forEach((row, index) => {
let orgData = this.makeData();
orgData.forEach((row, index) => {
const newRow = deepCopy(row); // todo
newRow._isHover = false;
if (newRow._disabled) {
@ -1030,6 +1055,85 @@ export default {
this.timer = setTimeout(() => {
this.scrollToRowIndex = -1;
}, 1800);
},
clear() {
this.currentIndex = -1;
this.placeholderHeight = 0;
this.topPlaceholderHeight = 0;
this.bottomPlaceholderHeight = 0;
},
handleStyle() {
this.placeholderHeight = this.totalRowHeight - this.moduleHeight * 3; // ( + )
this.topPlaceholderHeight =
parseInt(this.scrollTop / this.moduleHeight) * this.moduleHeight;
this.bottomPlaceholderHeight =
this.placeholderHeight - this.topPlaceholderHeight < 0
? 0
: this.placeholderHeight - this.topPlaceholderHeight;
this.currentIndex = parseInt(
(this.scrollTop % (this.moduleHeight * 3)) / this.moduleHeight
);
},
setScrollData(data) {
let scrollTop = this.scrollTop;
let t0 = 0;
let t1 = 0;
let t2 = 0;
if (scrollTop > this.moduleHeight) {
switch (this.currentIndex) {
case 0:
t0 = parseInt(scrollTop / (this.moduleHeight * 3));
t1 = t2 = t0;
break;
case 1:
t1 = parseInt(
(scrollTop - this.moduleHeight) / (this.moduleHeight * 3)
);
t0 = t1 + 1;
t2 = t1;
break;
case 2:
t2 = parseInt(
(scrollTop - this.moduleHeight * 2) / (this.moduleHeight * 3)
);
t0 = t1 = t2 + 1;
}
}
let count1 = t0 * this.showRowNum * 3;
let table1 = data.slice(count1, count1 + this.showRowNum);
let count2 = t1 * this.showRowNum * 3;
let table2 = data.slice(
count2 + this.showRowNum,
count2 + this.showRowNum * 2
);
let count3 = t2 * this.showRowNum * 3;
let table3 = data.slice(
count3 + this.showRowNum * 2,
count3 + this.showRowNum * 3
);
let scrollData = [];
switch (this.currentIndex) {
case 0:
scrollData = [].concat(table1, table2, table3);
break;
case 1:
scrollData = [].concat(table2, table3, table1);
break;
case 2:
scrollData = [].concat(table3, table1, table2);
}
console.log(5);
return scrollData;
}
},
created() {
@ -1037,6 +1141,7 @@ export default {
this.showSlotHeader = this.$slots.header !== undefined;
this.showSlotFooter = this.$slots.footer !== undefined;
this.rebuildData = this.makeDataWithSortAndFilter();
console.log(2);
},
mounted() {
this.handleResize();
@ -1051,6 +1156,7 @@ export default {
this.handleResize();
}
});
console.log(3);
},
beforeDestroy() {
off(window, "resize", this.handleResize);
@ -1070,6 +1176,7 @@ export default {
setTimeout(() => {
this.cloneData = deepCopy(this.data);
}, 0);
console.log(1);
},
deep: true
},
@ -1085,6 +1192,7 @@ export default {
this.rightFixedColumnRows = this.makeColumnRows("right", colsWithId);
this.rebuildData = this.makeDataWithSortAndFilter();
this.handleResize();
console.log(4);
},
deep: true
},

View File

@ -1,5 +1,13 @@
import * as API from 'api/real/orders';
let remove_selected = (selected, array) => {
return selected.filter(el => {
return array.findIndex(e => {
return e._rowIndex === el._rowIndex;
}) === -1;
});
};
const state = {
order_group: {}, // 订单组
real_orders: [], // RD订单
@ -24,36 +32,58 @@ const getters = {
relationObj: state => state.relationObj,
orders: state => state.real_orders,
cards: state => state.cards,
selected: state => state.selected,
counts: (state) => {
if (!state.selected.length) {
order_group: (state) => {
let order_group = {};
for (const index in state.order_group) {
if (state.order_group.hasOwnProperty(index)) {
const element = state.order_group[index];
order_group[index] = element.map(el => {
return state.cards.find(e => {
return e._rowIndex === el;
});
});
}
}
return order_group;
},
selected: (state) => {
return state.selected.map(el => {
return state.cards.find(e => { return e._rowIndex === el; });
});
},
total: (state) => {
if (!state.cards.length) {
return 0;
}
return state.selected.reduce((acc, cur) => {
return state.cards.reduce((acc, cur) => {
return acc + cur.counts;
}, 0);
},
counts: (state, getters) => {
if (!getters.selected.length) {
return 0;
}
return getters.selected.reduce((acc, cur) => {
return acc + cur.counts;
}, 0);
},
getFilterUsedCards: () => (cards) => {
return cards.filter(item => item.virtual_order_id === 0);
},
getRealOrderById: (state) => (id) => {
return state.real_orders.find(item => item.id === id);
},
getSelectedByOrderId: (state) => (order_id) => {
getSelectedByOrderId: (state, getters) => (order_id) => {
if (typeof order_id !== 'object') {
order_id = [order_id];
}
return state.selected.filter(item => {
return getters.selected.filter(item => {
return order_id.includes(item.order_id);
});
},
getCardByOderIdAndSim: (state) => (order_id, sim) => {
return state.selected.find(item => {
return item.order_id === order_id && item.sim === sim;
});
},
real_companies: (state) => {
return state.real_orders.map(el => { return el.company_name; }).filter((v, i, s) => { return s.indexOf(v) === i; });
},
@ -88,58 +118,16 @@ const mutations = {
state.orderParams = obj;
},
PUSH_CARDS(state, cards) {
state.cards = state.cards.concat(cards.filter(item => {
let data = cards.filter(el => {
return state.cards.findIndex(v => {
return v.sim === item.sim && v.order_id === item.order_id;
return v.sim === el.sim && v.order_id === el.order_id;
}) === -1;
}));
});
let concatCards = state.cards.concat(data);
state.cards = concatCards;
},
SET_SELECTED(state, data) {
state.selected = data;
},
PUSH_SELECTED(state, array) {
let selected = JSON.parse(JSON.stringify(state.selected));
for (let index = 0; index < array.length; index++) {
const element = array[index];
let i = selected.findIndex(item => {
return item.order_id === element.order_id && item.sim === element.sim;
});
if (i !== -1) {
selected.splice(i, 1);
}
let obj = element;
selected.push(obj);
}
state.selected = selected;
},
REMOVE_SELECTED(state, array) {
let selected = state.selected.map(item => {
return JSON.parse(JSON.stringify(item));
});
for (let index = 0; index < array.length; index++) {
const element = array[index];
let i = 0;
while (i !== -1) {
i = selected.findIndex(item => {
return element.sim ? (item.order_id === element.order_id && item.sim === element.sim) : (item.order_id === element.order_id);
});
if (i !== -1) {
selected.splice(i, 1);
}
}
}
state.selected = selected;
}
};
@ -225,22 +213,16 @@ const actions = {
return resolve(cards);
}
API.cards({ order_id: array, type }).then(res => {
let index = context.state.cards.length;
let params = { order_id: array, type };
API.cards(params).then(res => {
if (res.code === 0) {
let data = res.data;
data.map(row => {
row._index = index++;
row._rowIndex = row.sim + row.order_id;
});
context.commit('PUSH_CARDS', data);
let cards = context.state.cards.filter(v => {
return order_id.indexOf(v.order_id) !== -1;
});
resolve(cards);
console.log('cards', data);
resolve(data);
} else {
reject(res);
}
@ -253,8 +235,14 @@ const actions = {
return new Promise((resolve, reject) => {
API.cards(params).then(res => {
if (res.code === 0) {
context.commit('PUSH_CARDS', res.data);
resolve(res.data);
let data = res.data;
data.map(row => {
row._rowIndex = row.sim + row.order_id;
});
context.commit('PUSH_CARDS', data);
resolve(data);
} else {
reject(res);
}
@ -262,6 +250,30 @@ const actions = {
reject(err);
});
});
},
pushSelected(context, array) {
let selected = JSON.parse(JSON.stringify(context.getters.selected));
selected = remove_selected(selected, array);
array.map(el => { selected.push(el); });
context.commit('SET_SELECTED', selected.map(el => { return el._rowIndex; }));
},
removeSelected(context, array) {
let selected = JSON.parse(JSON.stringify(context.getters.selected));
selected = remove_selected(selected, array);
context.commit('SET_SELECTED', selected.map(el => { return el._rowIndex; }));
},
removeSelectedByOrderId(context, order_id) {
if (typeof order_id !== 'object') {
order_id = [order_id];
}
let array = context.state.cards.filter(el => {
return order_id.indexOf(el.order_id) !== -1;
});
context.dispatch('removeSelected', array);
}
};

View File

@ -105,7 +105,7 @@ export default {
if (this.circle.percent < max) {
this.circle.percent++;
}
}, 1000);
}, 1500);
service.post('/api/artisan/call', params).then(res => {
if (res.code == 0) {

View File

@ -16,7 +16,7 @@
<a @click="sort" class="umar-r10">
<b>已选{{counts}}</b>
</a>
<a @click="clear">
<a @click="clearSelect">
<b>清空</b>
</a>
</Row>
@ -153,6 +153,7 @@
:loading="cardLoading"
:columns="cardColumns"
:data="showCards ? showCards : []"
disabled-hover
stripe
border
:height="449"

View File

@ -32,7 +32,7 @@ export default {
this.$store.commit('SET_RELATION_OBJ', value);
}
},
...mapGetters(['orders', 'cards', 'selected', 'counts', 'getFilterUsedCards', 'getRealOrderById', 'getSelectedByOrderId', 'getCardByOderIdAndSim', 'relations', 'real_companies', 'real_packages'])
...mapGetters(['orders', 'cards', 'selected', 'counts', 'getFilterUsedCards', 'getSelectedByOrderId', 'relations', 'real_companies', 'real_packages'])
},
data() {
return {
@ -215,7 +215,6 @@ export default {
value = !!this.selected.length;
indeterminate = this.selected.length && this.selected.length !== this.showCards.length;
return h("Checkbox", {
props: {
indeterminate: value && indeterminate,
@ -225,37 +224,16 @@ export default {
input: value => {
if (value) {
let cards = this.getFilterUsedCards(this.showCards);
let array = cards.map(item => {
return {
order_id: item.order_id,
sim: item.sim,
counts: item.counts,
virtual_order_id: item.virtual_order_id,
company_id: item.company_id,
package_id: item.package_id
};
});
this.$store.commit('PUSH_SELECTED', array);
this.$store.dispatch('pushSelected', cards);
} else {
let array = this.showCards.map(item => {
return { order_id: item.order_id, sim: item.sim };
});
this.$store.commit('REMOVE_SELECTED', array);
this.$store.dispatch('removeSelected', this.showCards);
}
}
}
});
},
render: (h, context) => {
let value = false;
let select = this.getCardByOderIdAndSim(context.row.order_id, context.row.sim);
value = !!select;
let value = this.selected.findIndex(el => { return el._rowIndex === context.row._rowIndex; }) !== -1;
return h("Checkbox", {
props: {
value: value,
@ -263,12 +241,19 @@ export default {
},
on: {
input: value => {
this.handleSelectCards(context.row, value);
let action = value ? 'pushSelected' : 'removeSelected';
this.$store.dispatch(action, [context.row]);
}
}
});
}
},
{
title: "序号",
key: "_index",
width: 135,
sortable: true
},
{
title: "SIM",
key: "sim",
@ -416,6 +401,9 @@ export default {
clear() {
this.$store.dispatch('initOrder');
},
clearSelect() {
this.$store.commit('SET_SELECTED', []);
},
cannel() {
this.clear();
this.close();
@ -443,30 +431,21 @@ export default {
this.cardLoading = false;
this.showCards = cards;
// 跳转到选择的行
this.$nextTick(() => {
if (typeof order_id !== 'object') {
let index = this.showCards.findIndex(el => { return el.order_id === order_id; });
let toIndex = index - 5 > 0 ? index - 5 : 0;
this.$refs.cardSelection.scrollToRow(toIndex);
}
});
// this.$nextTick(() => {
// if (typeof order_id !== 'object') {
// let index = this.showCards.findIndex(el => { return el.order_id === order_id; });
// let toIndex = index - 5 > 0 ? index - 5 : 0;
// this.$refs.cardSelection.scrollToRow(toIndex);
// }
// });
resolve(cards);
}).catch((err) => {
this.cardLoading = false;
this.$Message.error("服务器出错,请稍后再试");
});
});
},
handleSelectOrder(order_id, value, counts = null) {
if (typeof order_id !== 'object') {
order_id = [order_id];
}
let remove = order_id.map(el => {
return { order_id: el };
});
this.$store.commit('REMOVE_SELECTED', remove);
this.$store.dispatch('removeSelectedByOrderId', order_id);
if (!value) {
return;
@ -496,13 +475,9 @@ export default {
});
}
this.$store.commit('PUSH_SELECTED', arr);
this.$store.dispatch('pushSelected', arr);
});
},
handleSelectCards(row, value) {
let action = value ? 'PUSH_SELECTED' : 'REMOVE_SELECTED';
this.$store.commit(action, [row]);
},
order() {
if (this.selected.findIndex(el => { return el.virtual_order_id !== 0; }) !== -1) {
return this.$Message.error('所选数据存在已使用的卡');
@ -516,9 +491,9 @@ export default {
let key = element.company_id + '_' + element.package_id;
if (group.hasOwnProperty(key)) {
group[key].push(element);
group[key].push(element._rowIndex);
} else {
group[key] = [element];
group[key] = [element._rowIndex];
}
}

View File

@ -63,7 +63,7 @@ export default {
},
order_group: {
get() {
return this.$store.state.order.order_group;
return this.$store.getters.order_group;
},
set(value) {
this.$store.commit('SET_ORDER_GROUP', value);
@ -148,13 +148,19 @@ export default {
return this.$Message.error('请选择一个订单组');
}
this.params.selected = this.group.map(el => {
return { order_id: el.order_id, counts: el.counts, sim: el.sim };
});
if (this.groupIndex === '0_0') {
// 卡不在VD上转销售
this.params.type = -1;
this.params.type = 0;
this.params.sign = 1;
this.post();
} else if (this.params.company_id !== this.group[0].company_id) {
// 改企业的
this.params.type = -2;
this.params.type = 0;
this.params.sign = 2;
this.$Modal.confirm({
title: '提示',
content: '是否确认修改所选卡的企业?',
@ -162,11 +168,9 @@ export default {
this.post();
}
});
} else {
this.post();
}
this.params.selected = this.group.map(el => {
return { order_id: el.order_id, counts: el.counts, sim: el.sim };
});
} else if (this.selected.length) {
this.params.selected = this.selected.map(el => {
return { order_id: el.order_id, counts: el.counts, sim: el.sim };
@ -360,14 +364,20 @@ export default {
handelSuccess() {
if (Object.keys(this.order_group).length >= 1) {
let mapped = JSON.parse(JSON.stringify(this.order_group));
this.$store.commit('REMOVE_SELECTED', mapped[this.groupIndex]);
this.$store.dispatch('removeSelected', mapped[this.groupIndex]);
delete mapped[this.groupIndex];
this.order_group = mapped;
if (Object.keys(this.order_group).length >= 1) {
let key = Object.keys(this.order_group)[0];
this.selectGroup(this.order_group[key], key);
let group = {};
for (const k in mapped) {
const element = mapped[k];
group[k] = element.map(el => {
return el._rowIndex;
});
}
this.$store.commit('SET_ORDER_GROUP', group);
}
this.$Message.success('操作成功');

View File

@ -0,0 +1 @@
[data-v-554a0ba0] .ivu-table-cell{word-break:keep-all}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-12217672.0f76ed17.css rel=prefetch><link href=/css/chunk-aac852ec.251cac58.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-12217672.67e501de.js rel=prefetch><link href=/js/chunk-aac852ec.be64dbbe.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.5803e894.css rel=preload as=style><link href=/js/app.266531a3.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.5803e894.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.266531a3.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-2bc30b38.e8c4cfa7.css rel=prefetch><link href=/css/chunk-cc3e3910.48b8d490.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-2bc30b38.23fc3fe0.js rel=prefetch><link href=/js/chunk-cc3e3910.6c368787.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.5803e894.css rel=preload as=style><link href=/js/app.ef71b9d2.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.5803e894.css rel=stylesheet><link href=/css/app.d71a8195.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.ef71b9d2.js></script></body></html>

View File

@ -1,12 +1,10 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Query\Grammars\Grammar;
use App\Models\Card\Card;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
require_once realpath(dirname(__FILE__) . '/TestCase.php');
$res = Card::selectRaw('MAX(SUBSTR(sim::text, 4, 1)) as max')
->whereRaw("sim::text SIMILAR TO '106\d244756200|106\d244756201|106_852546016|104_340502885'")
->first();
dd($res);
Schema::table("virtual_orders", function (Blueprint $table) {
$table->tinyInteger('sign')->default(0)->comment('特殊标记 0:非特殊 -1:不在VD上的改企业转销售 -2改企业的转销售');;
});