|
@@ -0,0 +1,589 @@
|
|
|
+<template>
|
|
|
+ <div class="form-submit">
|
|
|
+ <div class="i-layout-page-header">
|
|
|
+ <PageHeader class="product_tabs" hidden-breadcrumb>
|
|
|
+ <div slot="title">
|
|
|
+ <router-link :to="{ path: `${roterPre}/erp/store_stock` }">
|
|
|
+ <!-- <Button icon="ios-arrow-back" size="small" class="mr20"
|
|
|
+ >返回</Button
|
|
|
+ > -->
|
|
|
+ <div class="font-sm after-line">
|
|
|
+ <span class="iconfont iconfanhui"></span>
|
|
|
+ <span class="pl10">返回</span>
|
|
|
+ </div>
|
|
|
+ </router-link>
|
|
|
+ <span v-text="
|
|
|
+ $route.query.id !== '0' ? '编辑门店盘点单' : '添加门店盘点单'
|
|
|
+ " class="mr20 ml16"></span>
|
|
|
+ </div>
|
|
|
+ </PageHeader>
|
|
|
+ </div>
|
|
|
+ <Card :bordered="false" dis-hover class="ivu-mt">
|
|
|
+ <Form class="formValidate mt20" ref="formValidate" :rules="ruleValidate" :model="formValidate"
|
|
|
+ :label-width="labelWidth" :label-position="labelPosition" @submit.native.prevent>
|
|
|
+ <Row :gutter="24" type="flex">
|
|
|
+ <Col span="24">
|
|
|
+ <FormItem label="门店:" prop="store_id">
|
|
|
+ <el-cascader placeholder="请选择门店" class="input-add" size="mini"
|
|
|
+ v-model="formValidate.store_id" :options="staffData" :props="propss"
|
|
|
+ @change="userSearchse" filterable v-width="'400'">
|
|
|
+ </el-cascader>
|
|
|
+ </FormItem>
|
|
|
+ </Col>
|
|
|
+
|
|
|
+ <Col span="24">
|
|
|
+ <FormItem label="创建人:" prop="create_uid" v-if="formValidate.store_id != 0 ">
|
|
|
+ <el-cascader placeholder="请选择创建人" class="input-add" size="mini"
|
|
|
+ v-model="formValidate.create_uid" :options="authList" :props="propsss" @change="userSearchsss"
|
|
|
+ filterable clearable v-width="'400'">
|
|
|
+ </el-cascader>
|
|
|
+ </FormItem>
|
|
|
+ </Col>
|
|
|
+ <Col span="24">
|
|
|
+ <FormItem label="商品:" prop="goods">
|
|
|
+ <Table :columns="columns" :data="chooseGoods" ref="table" :loading="loading"
|
|
|
+ no-userFrom-text="暂无数据" no-filtered-userFrom-text="暂无筛选结果">
|
|
|
+ <template slot-scope="{ row,index }" slot="new_stock">
|
|
|
+ <Input v-model="chooseGoods[index].new_stock" placeholder="请输入实盘" v-width="'150'" type="number" />
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row,index }" slot="unit_types">
|
|
|
+ {{row.unit_name}}
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row,index }" slot="store_num">
|
|
|
+ <span> {{ row.my.stock }}{{row.my.unit_name}}</span>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row, index }" slot="action">
|
|
|
+ <a @click="del(index)">删除</a>
|
|
|
+ </template>
|
|
|
+ </Table>
|
|
|
+ <Button type="primary" class="submission" style="margin-top:20px;" @click="getGoods()" v-if="formValidate.id == 0">选择商品</Button>
|
|
|
+ </FormItem>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </Form>
|
|
|
+ </Card>
|
|
|
+ <Card :bordered="false" dis-hover class="fixed-card"
|
|
|
+ :style="{ left: `${!menuCollapse ? '200px' : isMobile ? '0' : '80px'}` }">
|
|
|
+ <Form>
|
|
|
+ <FormItem>
|
|
|
+ <Button type="primary" class="submission" @click="handleSubmit('formValidate')">保存</Button>
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ </Card>
|
|
|
+ <good-detail ref="goodDetail" @setGoods="setGoods"></good-detail>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ mapState,
|
|
|
+ mapMutations
|
|
|
+ } from "vuex";
|
|
|
+ import {
|
|
|
+ staffListInfo
|
|
|
+ } from "@/api/store";
|
|
|
+ import {
|
|
|
+ getGodownList,
|
|
|
+ createGodown,
|
|
|
+ getGodownInfo,
|
|
|
+ getUserList,
|
|
|
+ getOutGoods,
|
|
|
+ createAdjust,
|
|
|
+ getWantInfo,
|
|
|
+ saveMdInventory,
|
|
|
+ infoMdInventory
|
|
|
+ } from "@/api/erp";
|
|
|
+ import {
|
|
|
+ keyApi,
|
|
|
+ storeGetInfoApi,
|
|
|
+ cityApi,
|
|
|
+ storeUpdateApi,
|
|
|
+ cascaderList
|
|
|
+ } from '@/api/store';
|
|
|
+ import {
|
|
|
+ productSpecs,
|
|
|
+ productSpecsInfo
|
|
|
+ } from "@/api/product";
|
|
|
+ import Setting from "@/setting";
|
|
|
+ import goodDetail from './goodDetail.vue'
|
|
|
+ export default {
|
|
|
+ name: "adjustAdd",
|
|
|
+ components: {
|
|
|
+ goodDetail
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ scale: 0,
|
|
|
+ loading: false,
|
|
|
+ authList: [],
|
|
|
+ columnss: [{
|
|
|
+ title: '商品名称',
|
|
|
+ key: 'product_name',
|
|
|
+ minWidth: 160
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '要货数量',
|
|
|
+ slot: 'want_product_num',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '要货单位',
|
|
|
+ key: 'unit_name',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ slot: 'action',
|
|
|
+ minWidth: 120
|
|
|
+ },],
|
|
|
+ columns: [{
|
|
|
+ title: 'ID',
|
|
|
+ key: 'product_id',
|
|
|
+ minWidth: 160
|
|
|
+ },{
|
|
|
+ title: '商品名称',
|
|
|
+ key: 'product_name',
|
|
|
+ minWidth: 160
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '单位',
|
|
|
+ key: 'unit_name',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '库存',
|
|
|
+ key: 'stock',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // title: '修改前价格',
|
|
|
+ // key: 'ot_price',
|
|
|
+ // minWidth: 90
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ title: '实盘',
|
|
|
+ slot: 'new_stock',
|
|
|
+ minWidth: 150
|
|
|
+ },
|
|
|
+
|
|
|
+ // {
|
|
|
+ // title: '门店库存',
|
|
|
+ // slot: 'store_num',
|
|
|
+ // minWidth: 120
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ slot: 'action',
|
|
|
+ minWidth: 120
|
|
|
+ },
|
|
|
+
|
|
|
+ ],
|
|
|
+ chooseGoods: [],
|
|
|
+ staffData: [],
|
|
|
+ addresData: [],
|
|
|
+ props: {
|
|
|
+ emitPath: false,
|
|
|
+ multiple: false,
|
|
|
+ checkStrictly: true,
|
|
|
+ value: "id",
|
|
|
+ label: "title"
|
|
|
+ },
|
|
|
+ propss: {
|
|
|
+ emitPath: false,
|
|
|
+ multiple: false,
|
|
|
+ checkStrictly: true,
|
|
|
+ value: "id",
|
|
|
+ label: "name"
|
|
|
+ },
|
|
|
+ propsss: {
|
|
|
+ emitPath: false,
|
|
|
+ multiple: false,
|
|
|
+ checkStrictly: true,
|
|
|
+ value: "id",
|
|
|
+ label: "staff_name"
|
|
|
+ },
|
|
|
+ roterPre: Setting.roterPre,
|
|
|
+ data1: [],
|
|
|
+ grid: {
|
|
|
+ xl: 7,
|
|
|
+ lg: 7,
|
|
|
+ md: 12,
|
|
|
+ sm: 24,
|
|
|
+ xs: 24,
|
|
|
+ },
|
|
|
+ formValidate: {
|
|
|
+ type: 0,
|
|
|
+ id: 0,
|
|
|
+ wid: 0,
|
|
|
+ store_id: 0,
|
|
|
+ goods: [],
|
|
|
+ my_store_id: 0,
|
|
|
+ create_uid: 0,
|
|
|
+ create_admin_id: 0,
|
|
|
+ scale: "",
|
|
|
+ },
|
|
|
+ ruleValidate: {
|
|
|
+ store_id: [{
|
|
|
+ type: "number",
|
|
|
+ required: true,
|
|
|
+ message: "请选择门店",
|
|
|
+ trigger: "blur"
|
|
|
+ }, ],
|
|
|
+ my_store_id: [{
|
|
|
+ type: "number",
|
|
|
+ required: true,
|
|
|
+ message: "请选择门店",
|
|
|
+ trigger: "blur"
|
|
|
+ }, ],
|
|
|
+ wid: [{
|
|
|
+ type: "number",
|
|
|
+ required: true,
|
|
|
+ message: "请选择仓库",
|
|
|
+ trigger: "blur"
|
|
|
+ }, ],
|
|
|
+ create_uid: [{
|
|
|
+ type: "number",
|
|
|
+ required: true,
|
|
|
+ message: "请选择创建人",
|
|
|
+ trigger: "blur"
|
|
|
+ }, ],
|
|
|
+ //integer
|
|
|
+ // scale: [{
|
|
|
+ // type: "number",
|
|
|
+ // required: true,
|
|
|
+ // message: "请输入调价比例",
|
|
|
+ // trigger: "blur"
|
|
|
+ // }]
|
|
|
+ // goods: [{
|
|
|
+ // type: "array",
|
|
|
+ // required: true,
|
|
|
+ // message: "请选择商品",
|
|
|
+ // trigger: "change"
|
|
|
+ // }, ],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState("admin/layout", ["isMobile", "menuCollapse"]),
|
|
|
+ labelWidth() {
|
|
|
+ return this.isMobile ? undefined : 120;
|
|
|
+ },
|
|
|
+ labelPosition() {
|
|
|
+ return this.isMobile ? "top" : "right";
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getGodownList()
|
|
|
+ let data = {
|
|
|
+ pid: 0
|
|
|
+ }
|
|
|
+ // this.cityInfo(data);
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // this.setCopyrightShow({
|
|
|
+ // value: false
|
|
|
+ // });
|
|
|
+ this.staffList()
|
|
|
+ if (this.$route.query.id != 0) {
|
|
|
+ this.getWantInfo(this.$route.query.id)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ destroyed() {
|
|
|
+ // this.setCopyrightShow({
|
|
|
+ // value: true
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapMutations("admin/layout", ["setCopyrightShow"]),
|
|
|
+ typeChange() {
|
|
|
+ this.chooseGoods = []
|
|
|
+ },
|
|
|
+ getWantInfo(id) {
|
|
|
+ infoMdInventory(id).then(res => {
|
|
|
+ console.log(res,'ddddd');
|
|
|
+ let data = res.data
|
|
|
+ this.formValidate.id = data.id
|
|
|
+ this.formValidate.create_uid = data.create_uid
|
|
|
+ this.chooseGoods = data.body
|
|
|
+ this.formValidate.store_id = data.store_id
|
|
|
+ console.log(this.formValidate.goods,'this.formValidate.goods');
|
|
|
+ this.getUserList({
|
|
|
+ store_id: this.formValidate.store_id
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setGoods(e) {
|
|
|
+ console.log(e, 'ddd');
|
|
|
+ let arr = this.chooseGoods.concat(e.map(e => {
|
|
|
+ let good = {
|
|
|
+ product_name:e.product_name,
|
|
|
+ product_id:e.product_id,
|
|
|
+ // price:e.my.price,
|
|
|
+ // ot_price: e.my.price,
|
|
|
+ stock: e.my.stock,
|
|
|
+ unit_name: e.my.unit_name,
|
|
|
+ new_stock: 0,
|
|
|
+ }
|
|
|
+ return good
|
|
|
+ }))
|
|
|
+
|
|
|
+ //
|
|
|
+ let uniqueArray = arr.reverse().filter(function(item, index, self) {
|
|
|
+ return !self.slice(index + 1).some(function(otherItem) {
|
|
|
+ return item.product_id === otherItem.product_id
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.chooseGoods = uniqueArray.reverse()
|
|
|
+ // try {
|
|
|
+ // let arr = e.map(item => {
|
|
|
+ // item.unitList = [{
|
|
|
+ // value: 0,
|
|
|
+ // label: item.info.unit_name
|
|
|
+ // }]
|
|
|
+ // if (item.info.unit_name_1) {
|
|
|
+ // item.unitList.push({
|
|
|
+ // value: 1,
|
|
|
+ // label: item.info.unit_name_1
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // if (item.info.unit_name_2) {
|
|
|
+ // item.unitList.push({
|
|
|
+ // value: 2,
|
|
|
+ // label: item.info.unit_name_2
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // item.want_product_num = 0
|
|
|
+ // return item
|
|
|
+ // })
|
|
|
+ // this.chooseGoods = this.chooseGoods.concat(arr)
|
|
|
+ // } catch (e) {
|
|
|
+ // //TODO handle the exception
|
|
|
+ // console.log('err', e);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ console.log(this.chooseGoods, 'this.chooseGoods');
|
|
|
+ },
|
|
|
+ getGoods() {
|
|
|
+ if(!this.formValidate.store_id) {
|
|
|
+ return this.$Message.error('请选择门店')
|
|
|
+ }
|
|
|
+ this.$refs.goodDetail.formValidate.store_id = this.formValidate.store_id
|
|
|
+ this.$refs.goodDetail.modals = true
|
|
|
+ this.$refs.goodDetail.getList()
|
|
|
+
|
|
|
+ },
|
|
|
+ getUserList() {
|
|
|
+ getUserList({
|
|
|
+ store_id: this.formValidate.store_id
|
|
|
+ }).then(res => {
|
|
|
+ // console.log(res);
|
|
|
+ this.authList = res.data.data
|
|
|
+ // .map(item => {
|
|
|
+ // item.id += ''
|
|
|
+ // return item
|
|
|
+ // });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ staffList() {
|
|
|
+ staffListInfo()
|
|
|
+ .then((res) => {
|
|
|
+ this.staffData = res.data
|
|
|
+ // .map(item => {
|
|
|
+ // item.id += ''
|
|
|
+ // return item
|
|
|
+ // });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.$Message.error(err.msg);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getGodownInfo(id) {
|
|
|
+ getGodownInfo(id).then(res => {
|
|
|
+ this.formValidate = res.data
|
|
|
+ this.formValidate.addressSelect = this.formValidate.addressSelect.map(item => item * 1)
|
|
|
+ console.log(this.formValidate.addressSelect);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addchack(e, selectedData) {
|
|
|
+ console.log(selectedData, 'selectedData');
|
|
|
+ e.forEach((i, index) => {
|
|
|
+ if (index == 0) {
|
|
|
+ this.formValidate.province = i
|
|
|
+ } else if (index == 1) {
|
|
|
+ this.formValidate.city = i
|
|
|
+ } else if (index == 2) {
|
|
|
+ this.formValidate.area = i
|
|
|
+ } else {
|
|
|
+ this.formValidate.street = i
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.formValidate.address = (selectedData.map(o => o.label)).join('/')
|
|
|
+ // console.log('this.formValidate.addressSelect',this.formValidate.addressSelect);
|
|
|
+
|
|
|
+ },
|
|
|
+ cityInfo(data) {
|
|
|
+ cityApi(data).then(res => {
|
|
|
+ this.addresData = res.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ loadData(item, callback) {
|
|
|
+ item.loading = true;
|
|
|
+ cityApi({
|
|
|
+ pid: item.value
|
|
|
+ }).then(res => {
|
|
|
+ item.children = res.data;
|
|
|
+ item.loading = false;
|
|
|
+ callback();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ getGodownList() {
|
|
|
+ getGodownList().then(res => {
|
|
|
+ console.log(res);
|
|
|
+ this.data1 = res.data.data
|
|
|
+ // .map(item => {
|
|
|
+ // item.id += ''
|
|
|
+ // return item
|
|
|
+ // });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ del(index) {
|
|
|
+ this.chooseGoods.splice(index, 1);
|
|
|
+ },
|
|
|
+ userSearchse(e) {
|
|
|
+ this.formValidate.create_uid = "";
|
|
|
+ this.chooseGoods = []
|
|
|
+ this.authList = []
|
|
|
+ this.getUserList()
|
|
|
+ },
|
|
|
+ userSearchs(e) {
|
|
|
+ this.formValidate.wid = 0
|
|
|
+ this.goods = []
|
|
|
+ },
|
|
|
+ userSearchss(e) {
|
|
|
+ this.formValidate.create_uid = "";
|
|
|
+ this.formValidate.store_id = 0
|
|
|
+ this.authList = []
|
|
|
+ this.goods = []
|
|
|
+ this.getUserList()
|
|
|
+ },
|
|
|
+ userSearchsss(e) {
|
|
|
+ if(e) {
|
|
|
+ let obj = this.authList.find(item => item.id == e)
|
|
|
+ this.formValidate.create_admin_id = obj.admin_id
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ handleSubmit(name) {
|
|
|
+ this.$refs[name].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.formValidate.id = this.$route.query.id;
|
|
|
+ let errIndex = 0
|
|
|
+ let arr = []
|
|
|
+ this.chooseGoods.forEach(item => {
|
|
|
+ arr.push({
|
|
|
+ unit_name: item.unit_name,
|
|
|
+ stock: item.stock,
|
|
|
+ new_stock: item.new_stock,
|
|
|
+ product_id: item.product_id,
|
|
|
+ product_name: item.product_name
|
|
|
+ })
|
|
|
+ })
|
|
|
+ saveMdInventory({
|
|
|
+ id: this.formValidate.id,
|
|
|
+ body: arr,
|
|
|
+ store_id: this.formValidate.store_id,
|
|
|
+ create_admin_id: this.formValidate.create_admin_id,
|
|
|
+ create_uid: this.formValidate.create_uid,
|
|
|
+ }).then(res => {
|
|
|
+ this.$Message.success(res.msg);
|
|
|
+ this.$router.push({
|
|
|
+ path: this.roterPre + "/erp/store_stock"
|
|
|
+ });
|
|
|
+ }).catch(err => {
|
|
|
+ this.$Message.error(err.msg);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // this.$Message.error("请输入参数模板名称");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="stylus">
|
|
|
+ .table {
|
|
|
+ /deep/.ivu-table-header table {
|
|
|
+ border: 0 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table-header thead tr th:nth-of-type(1) {
|
|
|
+ padding-left: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table td:nth-of-type(1) {
|
|
|
+ padding-left: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table-cell {
|
|
|
+ padding: 0 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table-border th,
|
|
|
+ /deep/.ivu-table-border td {
|
|
|
+ border-right: unset;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.ivu-table td {
|
|
|
+ height: 59px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-submit {
|
|
|
+ /deep/.ivu-card {
|
|
|
+ border-radius: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ margin-bottom: 79px;
|
|
|
+
|
|
|
+ .fixed-card {
|
|
|
+ position: fixed;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ left: 200px;
|
|
|
+ z-index: 99;
|
|
|
+ box-shadow: 0 -1px 2px rgb(240, 240, 240);
|
|
|
+
|
|
|
+ /deep/ .ivu-card-body {
|
|
|
+ padding: 15px 16px 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ivu-form-item {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/ .ivu-form-item-content {
|
|
|
+ margin-right: 124px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ivu-btn {
|
|
|
+ height: 36px;
|
|
|
+ padding: 0 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .after-line {
|
|
|
+ display: inline-block;
|
|
|
+ position: relative;
|
|
|
+ margin-right: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ml16 {
|
|
|
+ margin-left: 16px;
|
|
|
+ }
|
|
|
+</style>
|