|
|
@@ -3,129 +3,180 @@
|
|
|
<scroll-view scroll-y scroll-with-animation class="main-view">
|
|
|
<view class="space-view ex-table">
|
|
|
<block v-if="!$util.isEmpty(list.data)">
|
|
|
- <Tabel
|
|
|
- :headerBackgroundColor="'#F0F2F6'"
|
|
|
- :columns="columns"
|
|
|
- :dataList="list.data"
|
|
|
- :fontSize="28"
|
|
|
- :parentData="{
|
|
|
- dataList: list.data,
|
|
|
- upSortByIndex: upSortByIndex,
|
|
|
- downSortByIndex: downSortByIndex,
|
|
|
- delEvent: delEvent
|
|
|
- }"
|
|
|
- >
|
|
|
- <template v-slot="{ row, column, index, parentData }">
|
|
|
- <view v-if="column.custom == 'edit'" class="edit-td">
|
|
|
- <text
|
|
|
- :class="['iconfont', 'iconshangyi', { disabled: index == 0 }]"
|
|
|
- @click.stop="upSortByIndex(row, index)"
|
|
|
- ></text>
|
|
|
- <text
|
|
|
- :class="[
|
|
|
- 'iconfont',
|
|
|
- 'iconxiayi',
|
|
|
- { disabled: index >= parentData.dataList.length - 1 }
|
|
|
- ]"
|
|
|
- @click.stop="downSortByIndex(row, index)"
|
|
|
- ></text>
|
|
|
- <text class="iconfont iconbianji" @click.stop="editEvent(row, index)">
|
|
|
- </text>
|
|
|
- <text class="iconfont icondelete" @click.stop="delEvent(row, index)">
|
|
|
- </text>
|
|
|
- </view>
|
|
|
- </template>
|
|
|
- </Tabel>
|
|
|
+ <t-table :headerBackgroundColor="'#F0F2F6'" :fontSize="28">
|
|
|
+ <t-tr header>
|
|
|
+ <t-th v-for="(item, index) in columns" :key="index" :align="item.align">
|
|
|
+ {{ item.name }}
|
|
|
+ </t-th>
|
|
|
+ </t-tr>
|
|
|
+ <t-tr v-for="(item, index) in list.data" :key="item.id">
|
|
|
+ <t-td
|
|
|
+ v-for="(column, colIndex) in columns"
|
|
|
+ :key="colIndex"
|
|
|
+ :align="column.align"
|
|
|
+ :color="column.color"
|
|
|
+ >
|
|
|
+ <view v-if="column.custom == 'edit'" class="edit-td">
|
|
|
+ <template v-if="parentData.isSort">
|
|
|
+ <text
|
|
|
+ :class="['iconfont', 'iconshangyi', { disabled: index == 0 }]"
|
|
|
+ @click.stop="upSortByIndex(item, index)"
|
|
|
+ ></text>
|
|
|
+ <text
|
|
|
+ :class="[
|
|
|
+ 'iconfont',
|
|
|
+ 'iconxiayi',
|
|
|
+ { disabled: index >= parentData.dataList.length - 1 }
|
|
|
+ ]"
|
|
|
+ @click.stop="downSortByIndex(item, index)"
|
|
|
+ ></text>
|
|
|
+ </template>
|
|
|
+ <text
|
|
|
+ v-else
|
|
|
+ class="iconfont icondelete"
|
|
|
+ @click.stop="delEvent(item, index)"
|
|
|
+ >
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view v-else-if="column.custom">
|
|
|
+ <view class="input-td">
|
|
|
+ <input
|
|
|
+ type="number"
|
|
|
+ :value="item[column.dataIndex]"
|
|
|
+ @input="changeItem($event, item, column.dataIndex, index)"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view v-else>
|
|
|
+ {{ item[column.dataIndex] || "" }}
|
|
|
+ </view>
|
|
|
+ </t-td>
|
|
|
+ </t-tr>
|
|
|
+ </t-table>
|
|
|
</block>
|
|
|
<block v-else>
|
|
|
<AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
|
|
|
</block>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
-
|
|
|
<view class="under-bar">
|
|
|
- <button :class="['admin-button-com']" @click="addEvent">
|
|
|
+ <button
|
|
|
+ v-if="!isSort"
|
|
|
+ :class="['admin-button-com', 'default']"
|
|
|
+ @click="isSort = true"
|
|
|
+ >
|
|
|
+ 排序
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ v-else
|
|
|
+ :class="['admin-button-com', 'default']"
|
|
|
+ @click="isSort = false"
|
|
|
+ >
|
|
|
+ 取消排序
|
|
|
+ </button>
|
|
|
+ <button :class="['admin-button-com']" @click="showFlower = true">
|
|
|
添加
|
|
|
</button>
|
|
|
+ <!-- <button :class="['admin-button-com']" @click="">
|
|
|
+ 保存
|
|
|
+ </button> -->
|
|
|
</view>
|
|
|
- <ModalModule
|
|
|
- :show="showEdit"
|
|
|
- @cancel="closeModal"
|
|
|
- @click="affirmEvent"
|
|
|
- :title="editTitle"
|
|
|
- color="#333"
|
|
|
- :size="32"
|
|
|
- padding="30rpx 30rpx"
|
|
|
- >
|
|
|
- <template slot="customContent">
|
|
|
- <view class="inpput-cmd_bx">
|
|
|
- <input v-model="editInfo.name" placeholder="请输入分类名" />
|
|
|
- </view>
|
|
|
- </template>
|
|
|
- </ModalModule>
|
|
|
+ <AppFlowerSel
|
|
|
+ :selectList="list.data"
|
|
|
+ :show.sync="showFlower"
|
|
|
+ @select="changeFlowerEvent"
|
|
|
+ />
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import Tabel from "@/components/app-table";
|
|
|
import AppWrapperEmpty from "@/components/app-wrapper-empty";
|
|
|
import { list } from "@/mixins";
|
|
|
import {
|
|
|
- getFlowerCategoryListApi,
|
|
|
- updateFlowerCategoryApi,
|
|
|
- addFlowerCategoryApi
|
|
|
+ getFlowerListApi,
|
|
|
+ updateFlowerApi,
|
|
|
+ addFlowerApi,
|
|
|
+ deleteFlowerApi
|
|
|
} from "@/api/storehouse/flower";
|
|
|
-import ModalModule from "@/components/plugin/modal";
|
|
|
+import lodash from "lodash";
|
|
|
|
|
|
+import AppFlowerSel from "@/components/app-flower-sel";
|
|
|
export default {
|
|
|
- components: { Tabel, AppWrapperEmpty, ModalModule },
|
|
|
+ components: { AppFlowerSel, AppWrapperEmpty },
|
|
|
mixins: [list],
|
|
|
data() {
|
|
|
return {
|
|
|
- showEdit: false,
|
|
|
- editInfo: {
|
|
|
- name: "",
|
|
|
- id: null,
|
|
|
- inTurn: 0
|
|
|
- },
|
|
|
+ classId: null,
|
|
|
+ isSort: false,
|
|
|
+ showFlower: false,
|
|
|
columns: [
|
|
|
{
|
|
|
- name: "分类",
|
|
|
- dataIndex: "name",
|
|
|
+ name: "名称",
|
|
|
+ dataIndex: "itemName",
|
|
|
color: "info"
|
|
|
},
|
|
|
+ {
|
|
|
+ name: "库存预警",
|
|
|
+ width: 130,
|
|
|
+ color: "info",
|
|
|
+ align: "center",
|
|
|
+ dataIndex: "stockWarning",
|
|
|
+ custom: "warn"
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // name: "每扎重量(斤)",
|
|
|
+ // width: 130,
|
|
|
+ // color: "info",
|
|
|
+ // align: "center",
|
|
|
+ // dataIndex: "weight",
|
|
|
+ // custom: "weight"
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ name: "每扎采购价(元)",
|
|
|
+ width: 130,
|
|
|
+ color: "info",
|
|
|
+ align: "center",
|
|
|
+ dataIndex: "unitCost",
|
|
|
+ custom: "cost"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "每扎加价(元)",
|
|
|
+ width: 130,
|
|
|
+ color: "info",
|
|
|
+ align: "center",
|
|
|
+ dataIndex: "unitAddPrice",
|
|
|
+ custom: "price"
|
|
|
+ },
|
|
|
{
|
|
|
name: "操作",
|
|
|
- align: "right",
|
|
|
+ align: "center",
|
|
|
custom: "edit"
|
|
|
}
|
|
|
]
|
|
|
};
|
|
|
},
|
|
|
+ onLoad(options) {
|
|
|
+ const { classId } = options;
|
|
|
+
|
|
|
+ this.classId = classId;
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
onPullDownRefresh() {
|
|
|
this.resetList();
|
|
|
this._list().then(res => {
|
|
|
uni.stopPullDownRefresh();
|
|
|
});
|
|
|
},
|
|
|
- computed: {
|
|
|
- editTitle() {
|
|
|
- let title = "新增";
|
|
|
- if (this.editInfo && this.editInfo.id) {
|
|
|
- title = this.editInfo.name;
|
|
|
- }
|
|
|
- return title;
|
|
|
- }
|
|
|
- },
|
|
|
methods: {
|
|
|
- async init() {
|
|
|
+ async initData() {
|
|
|
this._list();
|
|
|
},
|
|
|
_list() {
|
|
|
let params = {
|
|
|
+ classId: this.classId,
|
|
|
page: this.list.page,
|
|
|
pageSize: this.list.pageSize
|
|
|
};
|
|
|
- return getFlowerCategoryListApi(params)
|
|
|
+ return getFlowerListApi(params)
|
|
|
.then(res => {
|
|
|
this.completes(res);
|
|
|
})
|
|
|
@@ -150,16 +201,18 @@ export default {
|
|
|
try {
|
|
|
let params = {
|
|
|
id: item.id,
|
|
|
- name: item.name,
|
|
|
+ stockWarning: item.stockWarning,
|
|
|
+ unitWeight: item.unitWeight,
|
|
|
+ unitCost: item.unitCost,
|
|
|
+ unitAddPrice: item.unitAddPrice,
|
|
|
inTurn: ++item.inTurn
|
|
|
};
|
|
|
- let api = updateFlowerCategoryApi;
|
|
|
+ let api = updateFlowerApi;
|
|
|
|
|
|
await api(params);
|
|
|
|
|
|
this.resetList();
|
|
|
await this._list();
|
|
|
- this.closeModal();
|
|
|
} catch (error) {}
|
|
|
},
|
|
|
async downSortByIndex(item, index) {
|
|
|
@@ -169,21 +222,23 @@ export default {
|
|
|
try {
|
|
|
let params = {
|
|
|
id: item.id,
|
|
|
- name: item.name,
|
|
|
+ stockWarning: item.stockWarning,
|
|
|
+ unitWeight: item.unitWeight,
|
|
|
+ unitCost: item.unitCost,
|
|
|
+ unitAddPrice: item.unitAddPrice,
|
|
|
inTurn: --item.inTurn
|
|
|
};
|
|
|
- let api = updateFlowerCategoryApi;
|
|
|
+ let api = updateFlowerApi;
|
|
|
|
|
|
await api(params);
|
|
|
|
|
|
this.resetList();
|
|
|
await this._list();
|
|
|
- this.closeModal();
|
|
|
} catch (error) {}
|
|
|
},
|
|
|
- async delEvent(item, index) {
|
|
|
+ delEvent(item, index) {
|
|
|
uni.showModal({
|
|
|
- title: `确认删除${item.name}`,
|
|
|
+ title: `确认删除${item.name || ""}`,
|
|
|
content: "",
|
|
|
showCancel: true,
|
|
|
cancelText: "取消",
|
|
|
@@ -193,11 +248,10 @@ export default {
|
|
|
success: async result => {
|
|
|
if (result.confirm) {
|
|
|
try {
|
|
|
- await deleteFlowerCategoryApi(item.id);
|
|
|
+ await deleteFlowerApi(item.id);
|
|
|
uni.showToast({
|
|
|
title: "删除成功"
|
|
|
});
|
|
|
-
|
|
|
this.resetList();
|
|
|
this._list();
|
|
|
} catch (error) {}
|
|
|
@@ -207,42 +261,43 @@ export default {
|
|
|
complete: () => {}
|
|
|
});
|
|
|
},
|
|
|
- editEvent(item) {
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pagesStorehouse/flower/manage?classId=${item.id}`,
|
|
|
- success: result => {},
|
|
|
- fail: () => {},
|
|
|
- complete: () => {}
|
|
|
- });
|
|
|
- },
|
|
|
- addEvent() {
|
|
|
- this.showEdit = true;
|
|
|
- },
|
|
|
- closeModal() {
|
|
|
- this.editInfo = {
|
|
|
- name: "",
|
|
|
- id: null,
|
|
|
- inTurn: 0
|
|
|
- };
|
|
|
- this.showEdit = false;
|
|
|
- },
|
|
|
- async affirmEvent() {
|
|
|
+ changeItem: lodash.debounce(function(e, item, key, index) {
|
|
|
+ console.log(33333, e);
|
|
|
try {
|
|
|
+ const {
|
|
|
+ detail: { value }
|
|
|
+ } = e;
|
|
|
let params = {
|
|
|
- ...this.editInfo
|
|
|
+ id: item.id,
|
|
|
+ stockWarning: item.stockWarning,
|
|
|
+ unitWeight: item.unitWeight,
|
|
|
+ unitCost: item.unitCost,
|
|
|
+ unitAddPrice: item.unitAddPrice
|
|
|
};
|
|
|
- let api = addFlowerCategoryApi;
|
|
|
-
|
|
|
- if (this.editInfo.id) {
|
|
|
- api = updateFlowerCategoryApi;
|
|
|
- }
|
|
|
- await api(params);
|
|
|
+ params[key] = value;
|
|
|
+ updateFlowerApi(params)
|
|
|
+ .then(data => {
|
|
|
+ uni.showToast({
|
|
|
+ title: "保存成功"
|
|
|
+ });
|
|
|
+ this.resetList();
|
|
|
+ this._list();
|
|
|
+ })
|
|
|
+ .catch(err => {});
|
|
|
+ } catch (error) {}
|
|
|
+ }, 500),
|
|
|
+ async changeFlowerEvent(item) {
|
|
|
+ try {
|
|
|
+ let options = {
|
|
|
+ itemId: item.id,
|
|
|
+ classId: this.classId
|
|
|
+ };
|
|
|
+ await addFlowerApi(options);
|
|
|
uni.showToast({
|
|
|
- title: "保存成功"
|
|
|
+ title: "添加成功"
|
|
|
});
|
|
|
this.resetList();
|
|
|
- await this._list();
|
|
|
- this.closeModal();
|
|
|
+ this._list();
|
|
|
} catch (error) {}
|
|
|
}
|
|
|
}
|
|
|
@@ -317,7 +372,7 @@ export default {
|
|
|
/deep/.edit-td {
|
|
|
.iconfont {
|
|
|
font-size: 40upx;
|
|
|
- margin: 0 20upx;
|
|
|
+ margin: 0 5upx;
|
|
|
&.disabled {
|
|
|
color: #eeeeee;
|
|
|
}
|
|
|
@@ -344,21 +399,5 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /deep/.inpput-cmd_bx {
|
|
|
- margin: 20upx 0;
|
|
|
-
|
|
|
- width: 100%;
|
|
|
-
|
|
|
- input {
|
|
|
- padding: 0 20upx;
|
|
|
- width: 100%;
|
|
|
- height: 100upx;
|
|
|
- line-height: 100upx;
|
|
|
- border: 1px solid #f3f3f3;
|
|
|
- border-radius: 20upx;
|
|
|
- font-size: 28upx;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
</style>
|