123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- <template>
- <div class="main-contain">
- <div class="position">
- <bread-crumb :crumbs='crumbs'></bread-crumb>
- <div style="float:right;">
- <el-button size="small" @click="back()" class="filter-item" >取 消</el-button>
- <el-button size="small" type="primary" @click="submit()" class="filter-item" >保 存</el-button>
- </div>
- </div>
-
- <div class="app-container">
-
- <sales-return-dialog ref="dialog" :propForm="propForm"
- :visibility="isVisibility"
- v-on:dialog-comfirm="comfirm"
- v-on:dialog-cancle="cancle"></sales-return-dialog>
-
- <div class="cell clearfix">
- <label class="title"><span class="name">出库时间</span> : </label>
- <el-date-picker size="small" v-model="warehouse_out_time" prefix-icon="el-icon-date" :editable="false" style="width: 196px;"
- type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"></el-date-picker>
- </div>
-
- <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
- <el-table :data="recordInfo.recordData" :class="signAndWeighBoxPatients" style="width: 100%" border
- max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
- >
-
- <el-table-column min-width="35" align="center">
-
- <template slot="header" slot-scope="scope">
- <span>商品类型<span style="color: red">*</span></span>
- </template>
-
- <template slot-scope="scope">
- <el-form-item style="padding-top: 15px">
- <el-input placeholder="请输入商品类型" v-model="scope.row.good_type_id"
- :value="typeName(scope.row.good_type_id)"
- @focus="showDialog(scope.$index, scope.row)"></el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column min-width="35" align="center">
- <template slot="header" slot-scope="scope">
- <span>规格名称<span style="color: red">*</span></span>
- </template>
- <template slot-scope="scope">
-
- <el-form-item style="padding-top: 15px">
- <el-input placeholder="请输入规格名称" v-model="scope.row.good_id"
- :value="specificationName(scope.row.good_id)"
- @focus="showDialog(scope.$index, scope.row)"></el-input>
- </el-form-item>
-
- </template>
- </el-table-column>
-
-
- <el-table-column min-width="23" align="center">
- <template slot="header" slot-scope="scope">
- <span>单价<span style="color: red">*</span></span>
- </template>
- <template slot-scope="scope">
- <!--<el-input type="number" v-model="scope.row.price" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
- <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price' style="padding-top: 17px">
- <el-input type="number" v-model="scope.row.price" ></el-input>
- </el-form-item>
-
-
- </template>
- </el-table-column>
-
- <el-table-column min-width="23" align="center">
- <template slot="header" slot-scope="scope">
- <span>出库数量<span style="color: red">*</span></span>
- </template>
- <template slot-scope="scope">
- <el-form-item :prop="'recordData.' + scope.$index + '.count'" :rules='tableRules.count' style="padding-top: 17px">
- <el-input type="number" v-model="scope.row.count" ></el-input>
- </el-form-item>
- </template>
- </el-table-column>
-
- <el-table-column label="总价" min-width="20" align="center">
- <template slot-scope="scope">
- {{calculate(scope.row.price*scope.row.count)}}
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="20" align="center">
- <template slot-scope="scope">
- <el-input v-model="scope.row.remark"></el-input>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" min-width="20">
- <template slot-scope="scope">
- <el-tooltip class="item" effect="dark" content="新增" placement="top">
-
- <el-button
- size="mini"
- type="primary"
- icon="el-icon-circle-plus-outline"
- @click="handleEdit(scope.$index, scope.row)">
- </el-button>
- </el-tooltip>
- <el-tooltip class="item" effect="dark" content="删除" placement="top">
-
- <el-button
- size="mini"
- type="danger"
- icon="el-icon-delete"
- @click="handleDelete(scope.$index, scope.row)">
- </el-button>
- </el-tooltip>
-
- </template>
- </el-table-column>
- </el-table>
- </el-form>
-
- </div>
- </div>
-
- </template>
-
- <script>
- import { uParseTime } from '@/utils/tools'
-
- import {
- deleteWarehouseOutInfo,
- getWarehouseOutInfo,
- getSalesReturnConfig,
- editWarehouseoutInfo
- } from '@/api/stock'
- import SalesReturnDialog from './Dialog/salesReturnDialog'
- import BreadCrumb from '../components/bread-crumb'
-
- export default {
- components: { BreadCrumb, SalesReturnDialog },
- name: 'salesReturnEdit',
-
- data() {
- return {
- crumbs: [
- { path: false, name: '库存管理' },
- { path: false, name: '出库单' },
- { path: false, name: '编辑出库单' }
- ],
- signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
-
- adminUserOptions: null,
- currentIndex: 0,
- warehouse_out_time: '',
- recordInfo: {
- recordData: [],
- stock_in_code: '',
- current_index: ''
-
- },
- tableRules: {
- count: [
- { required: true, message: '数量不能为空', trigge: 'blur' }
- ],
- price: [
- { required: true, message: '单价不能为空', trigger: 'blur' }
- ]
-
- },
- ruleForm: {
- manufacturer: [
- { required: true, message: '请选择厂商', trigger: 'change' }
- ]
- },
- // prop
- isVisibility: false,
- propForm: {
- goodType: [],
- goodInfo: [],
- goodUnit: [],
- title: '入库'
- },
-
- form: {
- manufacturer: '',
- dealer: ''
- },
- warehouseInfoList:[],
- warehouseOut: {},
- manufacturer: [],
- dealer: [],
- goodType: []
- }
- },
- methods: {
- comfirm: function(val) {
- this.$refs.dialog.hide()
-
- if (val.selectedGoodInfo.length > 0) {
- for (let i = val.selectedGoodInfo.length - 1; ; i--) {
- if (i == 0) {
- this.recordInfo.recordData[this.currentIndex].good_type_id = val.goodTypeId
- this.recordInfo.recordData[this.currentIndex].good_id = val.selectedGoodInfo[i].id
- } else {
- const tempForm = {}
- tempForm['id'] = 0
- tempForm['good_type_id'] = val.goodTypeId
- tempForm['good_id'] = val.selectedGoodInfo[i].id
- tempForm['count'] = ''
- tempForm['price'] = ''
- tempForm['remark'] = ''
- this.recordInfo.recordData.splice(this.currentIndex + 1, 0, tempForm)
- }
- }
- }
-
- this.currentIndex = -1
- }, cancle: function() {
- this.$refs.dialog.hide()
- }, GetConfigInfo: function() {
- const params = {
- type: this.$route.query.type
- }
- getSalesReturnConfig(params).then(response => {
- if (response.data.state == 0) {
- this.$message.error(response.data.msg)
- return false
- } else {
- var warehouseInfoList = response.data.data.warehouseInfoList
- this.warehouseInfoList = response.data.data.warehouseInfoList
-
- for (let i = 0; i < warehouseInfoList.length; i++) {
- this.propForm.goodInfo.push(warehouseInfoList[i].GoodInfo)
- this.propForm.goodType.push(warehouseInfoList[i].GoodInfo.GoodsType)
- }
- const obj3 = {}
- const obj4 = {}
- this.propForm.goodInfo = this.propForm.goodInfo.reduce((cur, next) => {
- obj4[next.id] ? '' : obj4[next.id] = true && cur.push(next)
- return cur
- }, [])
- this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
- obj3[next.id] ? '' : obj3[next.id] = true && cur.push(next)
- return cur
- }, [])
- }
- })
- }, typeName: function(good_type_id) {
- let name = ''
- for (let i = 0; i < this.propForm.goodType.length; i++) {
- if (this.propForm.goodType[i].id == good_type_id) {
- name = this.propForm.goodType[i].type_name
- }
- }
- return name
- }, specificationName: function(good_info_id) {
- let name = ''
- for (let i = 0; i < this.propForm.goodInfo.length; i++) {
- if (this.propForm.goodInfo[i].id == good_info_id) {
- name = this.propForm.goodInfo[i].specification_name
- }
- }
- return name
- }, handleEdit: function(index, row) {
- const tempObj = {}
- tempObj['id'] = 0
- tempObj['good_type_id'] = 0
- tempObj['good_id'] = 0
- tempObj['count'] = ''
- tempObj['price'] = ''
- tempObj['remark'] = ''
- this.recordInfo.recordData.push(tempObj)
- }, handleDelete: function(index, row) {
- if (row.id == 0) {
- this.recordInfo.recordData.splice(index, 1)
- } else {
- const params = {
- id: row.id
- }
- this.$confirm('确认删除该退货商品信息记录?', '删除退货商品信息记录', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteWarehouseOutInfo(params).then(response => {
- if (response.data.state == 0) {
- this.$message.error(response.data.msg)
- return false
- } else {
- this.$message.success('删除成功')
-
- this.recordInfo.recordData.splice(index, 1)
- }
- })
- }).catch(() => {
- })
- }
- }, getTime(val, temp) {
- if (val != 0) {
- return uParseTime(val, temp)
- } else {
- return ''
- }
- }, showDialog(index, row) {
- this.currentIndex = index
- for (let i = 0; i < this.warehouseInfoList.length; i++) {
- if (this.warehouseInfoList[i].manufacturer == this.form.manufacturer) {
- this.propForm.goodType.push(this.warehouseInfoList[i].GoodInfo.GoodsType)
- }
- }
- const obj3 = {}
- this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
- obj3[next.id] ? '' : obj3[next.id] = true && cur.push(next)
- return cur
- }, [])
- this.$refs.dialog.show()
- }, back() {
- this.$router.go(-1)
- }, submit() {
- this.$refs['tableForm'].validate((valid) => {
- if (valid) {
- const array = this.recordInfo.recordData
- for (let i = 0; i < array.length; i++) {
- if (array[i].good_type_id == 0) {
- this.$message.error('商品类型不能为空')
- return
- }
- if (array[i].good_id == 0) {
- this.$message.error('规格名称不能为空')
- return
- }
- }
-
- const params = {
- 'stockOut': this.recordInfo.recordData
- }
- editWarehouseoutInfo(params, this.warehouse_out_time, this.$route.query.id, this.$route.query.type,this.form.manufacturer).then(response => {
- if (response.data.state == 0) {
- this.$message.error(response.data.msg)
- return false
- } else {
- this.$message.success('退货成功')
- this.$router.back(-1)
- }
- })
- } else {
- return false
- }
- })
- }, GetOrderDetail: function(order_id) {
- const params = {
- 'id': order_id
- }
- getWarehouseOutInfo(params).then(response => {
- if (response.data.state == 0) {
- this.$message.error(response.data.msg)
- return false
- } else {
- for (let i = 0; i < response.data.data.list.length; i++) {
- response.data.data.list[i].price = response.data.data.list[i].price.toString()
- response.data.data.list[i].count = response.data.data.list[i].count.toString()
- this.recordInfo.recordData.push(response.data.data.list[i])
- }
- this.warehouseOut = response.data.data.info
- this.warehouse_out_time = this.getTime(this.warehouseOut.warehouse_out_time, '{y}-{m}-{d}')
- this.form.manufacturer = this.warehouseOut.manufacturer
-
- }
-
- if (this.recordInfo.recordData.length == 0) {
- const tempObj = {}
- tempObj['id'] = 0
- tempObj['good_type_id'] = 0
- tempObj['good_id'] = 0
- tempObj['count'] = ''
- tempObj['price'] = ''
- tempObj['remark'] = ''
- this.recordInfo.recordData.push(tempObj)
- }
- })
- }, calculate: function(val) {
- if (val == 0) {
- return ''
- }
- return Math.round(parseFloat(val) * 100) / 100
- }
- },
- created() {
- this.GetConfigInfo()
- this.propForm.goodUnit = this.$store.getters.good_unit
- const order_id = this.$route.query.id
- this.GetOrderDetail(order_id)
- }
-
- }
- </script>
-
- <style rel="stylesheet/css" lang="scss" scoped>
- .information {
- border: 1px #dcdfe6 solid;
- padding: 30px 20px 30px 20px;
-
- .border {
- border-bottom: 1px #dcdfe6 solid;
- margin: 0px 0 20px 0;
- }
-
- }
-
- .edit_separater {
- border-top: 1px solid rgb(233, 233, 233);
- margin-top: 15px;
- margin-bottom: 15px;
- }
-
- </style>
-
- <style>
- .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
- font-size: 12px;
- }
-
- .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
- background: #6fb5fa;
- }
-
- </style>
|