123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614 |
- <template>
- <div class="detail-container">
- <el-page-header @back="goBack" :content="listItem ? (flag ? '详情' : '编辑') : '新增'"></el-page-header>
- <el-divider></el-divider>
- <div>
- <el-form
- ref="mainForm"
- :model="mainForm"
- :rules="mainFormRules"
- label-width="80px"
- size="small"
- label-position="left"
- >
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="选择仓库" prop="warehouse">
- <el-select v-model="mainForm.warehouse" placeholder="请选择仓库" style="width: 100%" :disabled="flag">
- <el-option
- :label="item.name"
- :value="item.id"
- v-for="(item, index) in warehouseList"
- :key="index"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-button size="small" type="primary" v-if="!flag" @click="getDeliverList">确定</el-button>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
- <el-form-item label="预约日期" prop="date">
- <el-date-picker
- :disabled="flag"
- v-model="mainForm.date"
- type="date"
- value-format="yyyy-MM-dd"
- style="width: 100%"
- placeholder="选择日期"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="12" style="height: 51px">
- <el-form-item label="预约时段" prop="timeSlot">
- <el-radio-group v-model="mainForm.timeSlot" :disabled="flag">
- <el-radio :label="1">上午</el-radio>
- <el-radio :label="2">下午</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="提货方式" prop="pickupWay">
- <el-radio-group v-model="mainForm.pickupWay" :disabled="flag">
- <el-radio :label="item.dictCode" v-for="(item, index) in pickupWayList" :key="index">{{
- item.dictValue
- }}</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="提货人" prop="pickupMan" v-if="mainForm.pickupWay == '1'">
- <el-select v-model="mainForm.pickupMan" placeholder="全部" :disabled="flag" style="width: 100%">
- <el-option
- :label="item.takerName"
- :value="item.id"
- v-for="(item, index) in pickupManList"
- :key="index"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" v-if="mainForm.pickupWay == '1'">
- <el-form-item label="提货车辆" prop="pickupCar">
- <el-select v-model="mainForm.pickupCar" placeholder="全部" style="width: 100%" :disabled="flag">
- <el-option
- :label="item.carBrand"
- :value="item.id"
- v-for="(item, index) in pickupCarList"
- :key="index"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" v-if="mainForm.pickupWay == '2'">
- <el-form-item label="物流公司" prop="company">
- <el-select
- v-model="mainForm.logisticsId"
- @change="getLogisticsId"
- placeholder="全部"
- style="width: 100%"
- :disabled="flag"
- >
- <el-option
- :label="item.logisticsCompany"
- :value="item.id"
- v-for="(item, index) in companyList"
- :key="index"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <template v-if="logisticsNumber === '001'">
- <el-col :xs="24" :sm="8" :lg="8">
- <el-form-item label="收货客户" :prop="logisticsNumber === '001' ? 'receivingName' : ''">
- <el-input v-model="mainForm.receivingName" :disabled="flag" placeholder="请输入收货客户"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="8" :lg="8">
- <el-form-item label="电话" :prop="logisticsNumber === '001' ? 'phone' : ''">
- <el-input v-model="mainForm.phone" :disabled="flag" placeholder="请输入电话"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="8" :lg="8">
- <el-form-item label="收货地址" :prop="logisticsNumber === '001' ? 'address' : ''">
- <el-input v-model="mainForm.address" :disabled="flag" placeholder="请输入收货地址"></el-input>
- </el-form-item>
- </el-col>
- </template>
- <el-col :xs="24" :sm="24" :lg="24">
- <el-form-item label="备注内容" prop="remark">
- <el-input v-model="mainForm.remark" :disabled="flag" placeholder="请输入备注内容"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <div class="mymain-container">
- <div class="table">
- <el-table
- ref="table"
- v-loading="listLoading"
- :data="deliverList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- @select="handleSelect"
- @select-all="handleSelectAll"
- >
- <el-table-column align="center" type="selection" width="55"></el-table-column>
- <template v-if="mainForm.pickupWay == 2 && logisticsNumber == '001'">
- <el-table-column align="left" label="收货客户" prop="orderTime" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.receivingName"
- size="mini"
- @input="handleInput($event, scope.row.invoiceId, 1)"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column align="left" label="电话" prop="orderTime" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.phone"
- size="mini"
- @input="handleInput($event, scope.row.invoiceId, 2)"
- ></el-input>
- </template>
- </el-table-column>
- <el-table-column align="left" label="收货地址" prop="orderTime" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.address"
- size="mini"
- @input="handleInput($event, scope.row.invoiceId, 3)"
- ></el-input>
- </template>
- </el-table-column>
- </template>
- <el-table-column
- align="left"
- label="发货申请单"
- prop="invoiceId"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column align="left" label="单据日期" prop="orderTime" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">
- {{ scope.row.orderTime | dateToDayFilter }}
- </template>
- </el-table-column>
- <el-table-column align="left" label="销售订单号" prop="mainOrderId" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <CopyButton
- :copyText="
- scope.row.orderType === 'TRADE' ||
- scope.row.orderType === 'HOME' ||
- scope.row.orderType === 'REQUISITION_TRADE' ||
- scope.row.orderType === 'REQUISITION_HOME'
- ? scope.row.enginOrderNo
- : scope.row.mainOrderId
- "
- />
- <span>{{
- scope.row.orderType === 'TRADE' ||
- scope.row.orderType === 'HOME' ||
- scope.row.orderType === 'REQUISITION_TRADE' ||
- scope.row.orderType === 'REQUISITION_HOME'
- ? scope.row.enginOrderNo
- : scope.row.mainOrderId
- }}</span>
- </template>
- </el-table-column>
- <!-- <el-table-column align="left" label="工程编号" prop="enginOrderNo" min-width="140" show-overflow-tooltip></el-table-column> -->
- <el-table-column
- align="left"
- label="销售类型"
- prop="saleTypeName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="left"
- label="物料编码"
- prop="materialCode"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="left"
- label="产品名称"
- prop="materialName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="left"
- label="规格型号"
- prop="specification"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="left"
- label="单位"
- prop="unit"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="right"
- label="数量"
- prop="refundableQty"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- </el-table>
- </div>
- </div>
- <div class="page-footer">
- <div class="footer" :class="classObj">
- <el-button type="primary" @click="clickSubmitForm" v-if="!flag" :loading="formLoading">{{
- formLoading ? '提交中 ...' : '提 交'
- }}</el-button>
- <el-popconfirm title="确定重置吗?" @onConfirm="resetForm" style="margin-left: 10px" v-if="!listItem">
- <el-button slot="reference">重 置</el-button>
- </el-popconfirm>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {
- getWarehouseList,
- getDeliverList,
- getPickupManList,
- getPickupCarList,
- getCompanyList,
- addPickupBook,
- editPickupBook,
- getDetail,
- checkStock
- } from '@/api/supply/pickup'
- import { getDictList } from '@/api/common'
- export default {
- name: 'PickupForm',
- componentName: 'PickupForm',
- props: ['listItem', 'flag'],
- data() {
- return {
- deliverList: null, // 列表数据
- listLoading: false, // 列表加载loading
- mainForm: {
- // 筛选表单数据
- warehouse: '',
- date: '',
- timeSlot: '',
- pickupWay: '',
- pickupMan: '',
- pickupCar: '',
- company: '',
- remark: '',
- logisticsId: '',
- receivingName: '',
- phone: '',
- address: ''
- },
- mainFormRules: {
- date: [{ required: true, message: '请选择预约日期', trigger: 'change' }],
- timeSlot: [{ required: true, message: '请选择预约时段', trigger: 'change' }],
- pickupWay: [{ required: true, message: '请选择提货方式', trigger: 'change' }],
- pickupMan: [{ required: true, message: '请选择提货人', trigger: 'change' }],
- receivingName: [{ required: true, message: '请填写收货客户', trigger: 'change' }],
- phone: [{ required: true, message: '请填写电话', trigger: 'change' }]
- // address: [{ required: true, message: '请填写收货地址', trigger: 'change' }]
- },
- formLoading: false,
- tableSelection: [],
- warehouseList: [],
- pickupWayList: [],
- pickupManList: [],
- pickupCarList: [],
- companyList: [],
- logisticsNumber: ''
- }
- },
- computed: {
- sidebar() {
- return this.$store.state.app.sidebar
- },
- classObj() {
- return {
- hideSidebar: !this.sidebar.opened,
- openSidebar: this.sidebar.opened
- }
- }
- },
- created() {
- this.getWarehouseList()
- this.getPickupWayList()
- this.getPickupManList()
- this.getPickupCarList()
- this.getCompanyList()
- if (this.listItem) {
- this.getDetail()
- }
- },
- methods: {
- // 查询按钮权限
- checkBtnRole(value) {
- // let btnRole = this.$route.meta.roles;
- // if(!btnRole) {return true}
- // let index = btnRole.indexOf(value);
- // return index >= 0;
- return true
- },
- // 返回列表
- goBack() {
- this.$emit('backListFormDetail')
- },
- handleInput(e, id, type) {
- console.log(e)
- this.deliverList.forEach(k => {
- if (k.invoiceId === id) {
- switch (type) {
- case 1:
- k.receivingName = e
- break
- case 2:
- k.phone = e
- break
- default:
- k.address = e
- }
- }
- })
- },
- // 获取详情
- getDetail() {
- getDetail({ id: this.listItem.id }).then(res => {
- let data = res.data
- this.mainForm.warehouse = data.correspondId
- this.mainForm.date = data.pickTime.slice(0, 10)
- this.mainForm.timeSlot = Number(data.pickStatus)
- this.mainForm.pickupWay = String(data.pickType)
- this.mainForm.pickupMan = data.takerId
- this.mainForm.pickupCar = data.takerCarId
- this.mainForm.company = data.pickLogistics
- this.mainForm.remark = data.remark
- this.mainForm.logisticsId = data.logisticsId
- const item = this.companyList.find(k => k.id === data.logisticsId)
- this.logisticsNumber = item.logisticsNumber
- this.deliverList = data.invoicePickBeans
- console.log(this.deliverList)
- })
- },
- // 获取仓库列表
- getWarehouseList() {
- getWarehouseList({
- pageNum: 1,
- pageSize: -1
- }).then(res => {
- this.warehouseList = res.data.records
- })
- },
- // 获取提货方式列表
- getPickupWayList() {
- getDictList({ sysDictEnum: 'PICK' }).then(res => {
- this.pickupWayList = res.data
- })
- },
- // 获取提货人列表
- getPickupManList() {
- getPickupManList({
- pageNum: 1,
- pageSize: -1
- }).then(res => {
- this.pickupManList = res.data.records
- })
- },
- // 获取提货车辆列表
- getPickupCarList() {
- getPickupCarList({
- pageNum: 1,
- pageSize: -1
- }).then(res => {
- this.pickupCarList = res.data.records
- })
- },
- // 获取物流公司列表
- getCompanyList() {
- getCompanyList({
- pageNum: 1,
- pageSize: -1
- }).then(res => {
- this.companyList = res.data.records
- console.log(this.companyList)
- })
- },
- getLogisticsId(e) {
- console.log(this.companyList)
- const item = this.companyList.find(k => k.id === e)
- this.mainForm.company = item.logisticsCompany
- this.logisticsNumber = item.logisticsNumber
- if (this.logisticsNumber === '001' && this.deliverList && this.deliverList.length) {
- this.deliverList.forEach(k => {
- this.$set(k, 'receivingName', '')
- this.$set(k, 'phone', '')
- this.$set(k, 'address', '')
- })
- } else {
- if (this.deliverList && !this.deliverList.length) return
- this.deliverList.forEach(k => {
- delete k.receivingName
- delete k.phone
- delete k.address
- })
- }
- },
- // 查询列表
- getDeliverList() {
- if (!this.mainForm.warehouse) {
- return this.$errorMsg('请选择仓库')
- }
- this.listLoading = true
- getDeliverList({ correspondId: this.mainForm.warehouse }).then(res => {
- this.deliverList = res.data
- this.listLoading = false
- })
- },
- handleSelect(selection, row) {
- this.$refs.table.toggleRowSelection(row)
- this.deliverList.forEach(item => {
- if (item.invoiceId === row.invoiceId) {
- this.$refs.table.toggleRowSelection(item)
- }
- })
- this.tableSelection = this.$refs.table.selection
- // this.tableSelection = this.$refs.table.selection;
- },
- handleSelectAll(selection) {
- this.tableSelection = this.$refs.table.selection
- },
- clickSubmitForm() {
- this.$refs.mainForm.validate(valid => {
- if (valid) {
- if (this.tableSelection.length < 1) {
- return this.$errorMsg('请选择发货申请单')
- }
- let orderList = []
- this.tableSelection.forEach(item => {
- orderList.push(item.invoiceOrderId)
- })
- let params = {
- correspondId: this.mainForm.warehouse,
- pickTime: this.mainForm.date + ' 00:00:00',
- invoiceOrderIds: orderList.join(',')
- }
- checkStock(params).then(res => {
- if (res.data) {
- this.$confirm(res.data, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- this.submitForm()
- })
- .catch(() => {})
- } else {
- this.submitForm()
- }
- })
- }
- })
- },
- submitForm() {
- this.formLoading = true
- let takerName
- if (this.mainForm.pickupWay == '1') {
- takerName = this.pickupManList.find(o => o.id == this.mainForm.pickupMan).takerName
- }
- // let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
- let orderList = []
- this.tableSelection.forEach(item => {
- orderList.push({
- address: item.address,
- id: this.listItem ? item.id : '',
- invoiceOrderId: item.invoiceOrderId,
- materialCode: item.materialCode,
- materialId: item.materialId,
- materialName: item.materialName,
- materialOldNumber: item.materialOldNumber,
- phone: item.phone,
- pickActualTime: item.pickActualTime,
- pickId: item.pickId,
- printNum: item.printNum,
- printTime: item.printTime,
- receivingName: item.receivingName,
- status: item.status
- })
- })
- let params = {
- correspondId: this.mainForm.warehouse,
- // correspondName,
- pickTime: this.mainForm.date + ' 00:00:00',
- pickStatus: Number(this.mainForm.timeSlot),
- pickType: Number(this.mainForm.pickupWay),
- takerId: this.mainForm.pickupMan,
- takerName: takerName || '',
- remark: this.mainForm.remark,
- invoiceOrderIds: orderList
- }
- if (this.mainForm.pickupWay == '1') {
- params.takerCarId = this.mainForm.pickupCar
- }
- if (this.mainForm.pickupWay == '2') {
- params.pickLogistics = this.mainForm.company
- params.logisticsId = this.mainForm.logisticsId
- params.receivingName = this.mainForm.receivingName
- params.phone = this.mainForm.phone
- params.address = this.mainForm.address
- }
- if (this.listItem) {
- params.id = this.listItem.id
- editPickupBook(params)
- .then(res => {
- this.$successMsg('提交成功')
- this.goBack()
- this.$parent.getList()
- })
- .finally(res => {
- this.formLoading = false
- })
- } else {
- addPickupBook(params)
- .then(res => {
- this.$successMsg('提交成功')
- this.goBack()
- this.$parent.getList()
- })
- .finally(res => {
- this.formLoading = false
- })
- }
- },
- resetForm() {
- this.$refs.mainForm.resetFields()
- this.deliverList = []
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|