sendGoodModal.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <a-modal
  3. centered
  4. class="sendGood-detail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. v-model="isShow"
  8. :title="modalTit"
  9. @cancel="handleCommonCancel"
  10. width="60%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div class="common-main">
  13. <div style="display:flex;margin-bottom:10px;align-items: center;">
  14. <a-button @click="showGlModal=true" type="primary" class="button-info" ghost v-if="isEdit">选择关联单据</a-button>
  15. <div style="padding:0 15px;" v-if="sendBillStockOutList.length">
  16. <div>{{ customeName }},共 {{ sendBillStockOutList && sendBillStockOutList.length }} 个出库单,产品款数合计 <span>{{ productTotal&&productTotal.totalCategory }}</span> ,产品数量合计 <span>{{ productTotal&&productTotal.totalQty }}</span>。</div>
  17. </div>
  18. </div>
  19. <div style="margin-bottom:10px;" v-if="isEdit">
  20. <a-table :columns="glColumns" :pagination="false" :scroll="{ y: 200 }" :data-source="sendBillStockOutList" bordered>
  21. <!-- 客户名称 -->
  22. <template slot="buyerName" slot-scope="text, record">
  23. {{ record.buyerName || record.demanderName }}
  24. </template>
  25. <!-- 操作 -->
  26. <template slot="action" slot-scope="text, record">
  27. <a-button
  28. size="small"
  29. type="link"
  30. class="button-error"
  31. @click="delStockOutList(record)"
  32. >
  33. 删除
  34. </a-button>
  35. </template>
  36. </a-table>
  37. </div>
  38. <div class="toolsBar">
  39. <a-form-model
  40. ref="ruleForm"
  41. :model="form"
  42. :rules="rules"
  43. :label-col="formItemLayout.labelCol"
  44. :wrapper-col="formItemLayout.wrapperCol"
  45. >
  46. <a-row>
  47. <a-col span="8">
  48. <a-form-model-item label="托运日期" prop="sendDate">
  49. <a-date-picker :allowClear="false" inputReadOnly v-model="form.sendDate" :locale="locale"/>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col span="8">
  53. <a-form-model-item label="收货人" prop="customerCacateName">
  54. <a-input placeholder="请输入收货人(最多30字符)" :maxLength="30" v-model.trim="form.customerCacateName"></a-input>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col span="8">
  58. <a-form-model-item label="电话" prop="customerCacatePhone">
  59. <a-input placeholder="请输入电话" :maxLength="30" v-model.trim="form.customerCacatePhone"></a-input>
  60. </a-form-model-item>
  61. </a-col>
  62. <a-col span="24">
  63. <a-form-model-item label="详细地址" prop="customerAddressDetail" :label-col="{span:2}" :wrapper-col="{span:21}">
  64. <a-textarea placeholder="请输入详细地址(最多300字符)" :maxLength="300" v-model.trim="form.customerAddressDetail"></a-textarea>
  65. </a-form-model-item>
  66. </a-col>
  67. <a-col span="8">
  68. <a-form-model-item label="目的地">
  69. <a-input placeholder="请输入目的地(最多30字符)" :maxLength="30" v-model.trim="form.customerAddress"></a-input>
  70. </a-form-model-item>
  71. </a-col>
  72. <a-col span="8">
  73. <a-form-model-item label="物流电话" prop="transportTele">
  74. <a-input placeholder="请输入物流电话" :maxLength="30" v-model.trim="form.transportTele"></a-input>
  75. </a-form-model-item>
  76. </a-col>
  77. <a-col span="8">
  78. <a-form-model-item label="物流单号" prop="transportNo">
  79. <a-input placeholder="请输入物流单号" :maxLength="30" v-model.trim="form.transportNo"></a-input>
  80. </a-form-model-item>
  81. </a-col>
  82. <a-col span="8">
  83. <a-form-model-item label="付款方式">
  84. <v-select
  85. v-model="form.payType"
  86. ref="payType"
  87. code="SEND_BILL_PAY_TYPE"
  88. placeholder="请选择付款方式"
  89. allowClear></v-select>
  90. </a-form-model-item>
  91. </a-col>
  92. <a-col span="8">
  93. <a-form-model-item label="交货方式">
  94. <v-select
  95. v-model="form.handoverType"
  96. ref="handoverType"
  97. code="SEND_BILL_HANDOVER_TYPE"
  98. placeholder="请选择交货方式"
  99. allowClear></v-select>
  100. </a-form-model-item>
  101. </a-col>
  102. <a-col span="8">
  103. <a-form-model-item label="运费合计">
  104. <!-- <a-input disabled placeholder="请输入运费合计" v-model.trim="form.totalSendAmount"></a-input> -->
  105. {{ form.totalSendAmount ? toThousands(form.totalSendAmount) : '--' }}
  106. </a-form-model-item>
  107. </a-col>
  108. </a-row>
  109. </a-form-model>
  110. </div>
  111. <div>
  112. <a-table
  113. class="sTable"
  114. :columns="columns"
  115. :pagination="false"
  116. :scroll="{ y: 200 }"
  117. :data-source="tableData"
  118. bordered>
  119. <!-- 物品名称 -->
  120. <template slot="goodName" slot-scope="text, record">
  121. <a-select v-model="record.goodsName" placeholder="请选择物品" style="width: 100%">
  122. <a-select-option value="电池机油">
  123. 电池机油
  124. </a-select-option>
  125. <a-select-option value="易损件">
  126. 易损件
  127. </a-select-option>
  128. <a-select-option value="电池">
  129. 电池
  130. </a-select-option>
  131. <a-select-option value="机油">
  132. 机油
  133. </a-select-option>
  134. <a-select-option value="轮胎">
  135. 轮胎
  136. </a-select-option>
  137. </a-select>
  138. </template>
  139. <!-- 数量 -->
  140. <template slot="qty" slot-scope="text, record">
  141. <a-input-number style="width: 100%;" :precision="0" v-model="record.goodsQty" :min="1" :max="999999"></a-input-number>
  142. </template>
  143. <!-- 体积 -->
  144. <template slot="volume" slot-scope="text, record">
  145. <a-input-number style="width: 100%;" :precision="2" v-model="record.goodsVolume" :min="0" :max="999999"></a-input-number>
  146. </template>
  147. <!-- 重量 -->
  148. <template slot="weight" slot-scope="text, record">
  149. <a-input-number style="width: 100%;" :precision="2" v-model="record.goodsWeight" :min="0" :max="999999"></a-input-number>
  150. </template>
  151. <!-- 计费单价 -->
  152. <template slot="price" slot-scope="text, record">
  153. <a-input-number style="width: 100%;" :precision="2" v-model="record.unitPrice" :min="0" :max="999999"></a-input-number>
  154. </template>
  155. <!-- 运费 -->
  156. <template slot="freight" slot-scope="text, record">
  157. <a-input-number
  158. style="width: 100%;"
  159. :precision="2"
  160. @change="amountChange('transportAmount',record)"
  161. v-model="record.transportAmount"
  162. :min="0"
  163. :max="999999"></a-input-number>
  164. </template>
  165. <!-- 保价 -->
  166. <template slot="supportValue" slot-scope="text, record">
  167. <a-input-number style="width: 100%;" :precision="2" v-model="record.supportValue" :min="0" :max="999999"></a-input-number>
  168. </template>
  169. <!-- 送货费 -->
  170. <template slot="deliveryExpense" slot-scope="text, record">
  171. <a-input-number
  172. style="width: 100%;"
  173. :precision="2"
  174. @change="amountChange('sendAmount',record)"
  175. v-model="record.sendAmount"
  176. :min="0"
  177. :max="999999"></a-input-number>
  178. </template>
  179. <!-- 其他 -->
  180. <template slot="other" slot-scope="text, record">
  181. <a-input-number
  182. style="width: 100%;"
  183. :precision="2"
  184. @change="amountChange('otherAmount',record)"
  185. v-model="record.otherAmount"
  186. :min="0"
  187. :max="999999"></a-input-number>
  188. </template>
  189. <!-- 操作 -->
  190. <template slot="action" slot-scope="text, record, index">
  191. <a-button
  192. size="small"
  193. type="link"
  194. class="button-error"
  195. @click="handleDel(record,index)"
  196. >
  197. 删除
  198. </a-button>
  199. </template>
  200. </a-table>
  201. <div style="padding: 5px; border:1px solid #eee;border-radius:0 0 10px;border-top: 0;text-align:center;">
  202. <a-button @click="addItem()" type="link">+新增发货明细</a-button>
  203. </div>
  204. </div>
  205. </div>
  206. <div class="btn-box">
  207. <a-button size="large" @click="handleCommonCancel" v-if="isCancel">{{ cancelText }}</a-button>
  208. <a-button size="large" type="primary" @click="handleCommonOk">{{ okText }}</a-button>
  209. </div>
  210. </a-spin>
  211. <!-- 关联单据 -->
  212. <selectGlOrderModal
  213. ref="selGlModal"
  214. modalTit="选择关联单据"
  215. :chooseData="sendBillStockOutList"
  216. :openModal="showGlModal"
  217. @choose="getProductTotal"
  218. @cancel="showGlModal=false"></selectGlOrderModal>
  219. </a-modal>
  220. </template>
  221. <script>
  222. import { commonMixin } from '@/utils/mixin'
  223. import moment from 'moment'
  224. import locale from 'ant-design-vue/es/date-picker/locale/zh_CN'
  225. import { STable, VSelect } from '@/components'
  226. import selectGlOrderModal from './selectGlOrderModal.vue'
  227. import { sendBillInsert, sendBillFindBySn, sendBillUpdate, deleteSendBillStockOut } from '@/api/sendBill'
  228. export default {
  229. name: 'SendGoodModal',
  230. mixins: [commonMixin],
  231. components: { STable, VSelect, selectGlOrderModal },
  232. props: {
  233. openModal: { // 弹框显示状态
  234. type: Boolean,
  235. default: false
  236. },
  237. modalTit: { // 弹框标题
  238. type: String,
  239. default: null
  240. },
  241. okText: { // 确定 按钮文字
  242. type: String,
  243. default: '确定'
  244. },
  245. cancelText: { // 取消 按钮文字
  246. type: String,
  247. default: '取消'
  248. },
  249. isCancel: { // 是否显示 取消 按钮
  250. type: Boolean,
  251. default: true
  252. }
  253. },
  254. data () {
  255. return {
  256. locale,
  257. isShow: this.openModal, // 是否打开弹框
  258. disabled: false,
  259. spinning: false,
  260. showGlModal: false,
  261. form: {
  262. 'stockOutSnList': [], // 出库单列表
  263. 'sendDate': moment(), // 托运时间
  264. 'customerAddress': '', // 目的地
  265. 'customerAddressDetail': '', // 详细地址
  266. 'transportTele': '', // 物流电话
  267. 'transportNo': '', // 物流单号
  268. 'customerCacateName': '', // 收货人
  269. 'customerCacatePhone': '', // 收货人电话
  270. 'payType': '', // 收款方式
  271. 'handoverType': '', // 发货方式
  272. 'totalSendAmount': '', // 发货总费用
  273. 'sendBillDetailList': [] // 发货列表
  274. },
  275. rules: {
  276. sendDate: [{ required: true, message: '请选择托运日期', trigger: 'change' }],
  277. customerCacateName: [{ required: true, message: '请输入收货人', trigger: 'change' }],
  278. customerCacatePhone: [{ required: true, message: '请输入电话', trigger: 'change' }],
  279. customerAddressDetail: [{ required: true, message: '请输入详细地址', trigger: 'change' }]
  280. },
  281. formItemLayout: {
  282. labelCol: { span: 6 },
  283. wrapperCol: { span: 15 }
  284. },
  285. sendBillStockOutList: [],
  286. glColumns: [
  287. { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text } },
  288. { title: '出库单号', dataIndex: 'stockOutNo', width: '10%', align: 'center' },
  289. { title: '业务单号', dataIndex: 'outBizSubNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  290. { title: '出库类型', dataIndex: 'outBizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  291. { title: '发货编号', dataIndex: 'sendNo', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  292. { title: '客户名称', scopedSlots: { customRender: 'buyerName' }, width: '12%', align: 'center', ellipsis: true },
  293. { title: '收货客户名称', dataIndex: 'receiverName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  294. { title: '产品款数', dataIndex: 'productTotalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  295. { title: '产品数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  296. { title: '单据审核时间', dataIndex: 'auditTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  297. { title: '收款时间', dataIndex: 'settleTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  298. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  299. ],
  300. productTotal: null,
  301. tableData: [],
  302. columns: [
  303. { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  304. { title: '货物名称', dataIndex: 'goodsName', scopedSlots: { customRender: 'goodName' }, width: '10%', align: 'center' },
  305. { title: '件数', dataIndex: 'goodsQty', scopedSlots: { customRender: 'qty' }, width: '8%', align: 'center' },
  306. { title: '体积(m³)', dataIndex: 'goodsVolume', scopedSlots: { customRender: 'volume' }, width: '8%', align: 'center' },
  307. { title: '重量(kg)', dataIndex: 'goodsWeight', scopedSlots: { customRender: 'weight' }, width: '8%', align: 'center' },
  308. { title: '计费单价(元)', dataIndex: 'unitPrice', scopedSlots: { customRender: 'price' }, width: '9%', align: 'center' },
  309. { title: '运费(元)', dataIndex: 'transportAmount', scopedSlots: { customRender: 'freight' }, width: '9%', align: 'center' },
  310. { title: '保价(万)', dataIndex: 'supportValue', scopedSlots: { customRender: 'supportValue' }, width: '9%', align: 'center' },
  311. { title: '送货费', dataIndex: 'sendAmount', scopedSlots: { customRender: 'deliveryExpense' }, width: '9%', align: 'center' },
  312. { title: '其他', dataIndex: 'otherAmount', scopedSlots: { customRender: 'other' }, width: '8%', align: 'center' },
  313. { title: '合计', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  314. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  315. ],
  316. isEdit: false,
  317. customeName: ''
  318. }
  319. },
  320. methods: {
  321. // 新增,出库单和收货人信息
  322. setData (data, customeInfo) {
  323. this.sendBillStockOutList = data
  324. this.customeName = data[0].demanderName
  325. this.isEdit = false
  326. this.getProductTotal()
  327. if (customeInfo) {
  328. this.form.customerCacateName = customeInfo.consigneeName
  329. this.form.customerCacatePhone = customeInfo.consigneeTel
  330. this.form.customerAddressDetail = customeInfo.addr
  331. }
  332. },
  333. // 删除出库单
  334. delStockOutList (row) {
  335. const ri = this.sendBillStockOutList.findIndex(item => row.stockOutSn == item.stockOutSn)
  336. // 新加的
  337. if (row.id) {
  338. this.sendBillStockOutList.splice(ri, 1)
  339. this.getProductTotal()
  340. } else {
  341. // 删除后修改发货状态
  342. this.spinning = true
  343. deleteSendBillStockOut({ stockOutSn: row.stockOutSn, sendBillSn: this.form.sendBillSn }).then(res => {
  344. if (res.status == 200) {
  345. this.sendBillStockOutList.splice(ri, 1)
  346. this.getProductTotal()
  347. }
  348. this.spinning = false
  349. })
  350. }
  351. },
  352. // 编辑
  353. getDetail (data) {
  354. this.spinning = true
  355. this.isEdit = true
  356. this.customeName = data.customeName
  357. sendBillFindBySn({ sn: data.sendBillSn }).then(res => {
  358. console.log(res)
  359. this.spinning = false
  360. if (res.data) {
  361. this.sendBillStockOutList = res.data.sendBillStockOutList // 出库单
  362. this.tableData = res.data.detailList // 发货明细
  363. this.tableData.map((item, i) => {
  364. item.no = i + 1
  365. })
  366. // 统计出库单
  367. this.getProductTotal()
  368. // 基本信息
  369. this.form.customerCacateName = res.data.customerCacateName
  370. this.form.customerCacatePhone = res.data.customerCacatePhone
  371. this.form.customerAddress = res.data.customerAddress
  372. this.form.customerAddressDetail = res.data.customerAddressDetail
  373. this.form.transportTele = res.data.transportTele
  374. this.form.transportNo = res.data.transportNo
  375. this.form.sendDate = res.data.sendDate
  376. this.form.payType = res.data.payType
  377. this.form.handoverType = res.data.handoverType
  378. this.form.totalSendAmount = res.data.totalSendAmount
  379. this.form.sendBillNo = data.sendBillNo
  380. this.form.sendBillSn = data.sendBillSn
  381. }
  382. })
  383. },
  384. // 出库单数据统计
  385. getProductTotal () {
  386. const ret = {
  387. totalCategory: 0,
  388. totalQty: 0
  389. }
  390. const stockOutSnList = []
  391. this.sendBillStockOutList.map((item, index) => {
  392. item.no = index + 1
  393. ret.totalCategory = ret.totalCategory + item.productTotalCategory
  394. ret.totalQty = ret.totalQty + item.productTotalQty
  395. stockOutSnList.push(item.stockOutSn)
  396. })
  397. // 编辑时不需要传
  398. this.form.stockOutSnList = stockOutSnList
  399. this.productTotal = ret
  400. },
  401. // 计算运费合计
  402. getTotalSendAmount () {
  403. let ret = 0
  404. this.tableData.map((item, i) => {
  405. item.no = i + 1
  406. ret = ret + Number(item.totalAmount || 0)
  407. })
  408. this.form.totalSendAmount = ret.toFixed(2)
  409. },
  410. // 计算每行发货费用合计
  411. amountChange (key, record) {
  412. record.totalAmount = (record.transportAmount || 0) + (record.sendAmount || 0) + (record.otherAmount || 0)
  413. record.totalAmount = Number(record.totalAmount).toFixed(2)
  414. this.getTotalSendAmount()
  415. },
  416. // 删除
  417. handleDel (row, index) {
  418. this.tableData.splice(index, 1)
  419. this.getTotalSendAmount()
  420. },
  421. // 添加
  422. addItem () {
  423. const len = this.tableData.length
  424. this.tableData.push({
  425. 'no': len + 1,
  426. 'goodsName': undefined,
  427. 'goodsQty': '',
  428. 'goodsVolume': '',
  429. 'goodsWeight': '',
  430. 'unitPrice': '',
  431. 'transportAmount': '',
  432. 'supportValue': '',
  433. 'sendAmount': '',
  434. 'otherAmount': '',
  435. 'totalAmount': ''
  436. })
  437. },
  438. // 校验物品单
  439. vaildGood (key) {
  440. const ret = []
  441. this.tableData.map(item => {
  442. ret.push(!!item[key])
  443. })
  444. console.log(ret)
  445. return ret
  446. },
  447. // 确定
  448. handleCommonOk () {
  449. const _this = this
  450. if (_this.form.stockOutSnList.length == 0 && !this.isEdit) {
  451. _this.$message.info('请选择出库单!')
  452. return
  453. }
  454. this.$refs.ruleForm.validate(valid => {
  455. _this.form.sendBillDetailList = _this.tableData
  456. if (valid) {
  457. console.log(_this.form, this.isEdit)
  458. if (_this.form.sendBillDetailList.length == 0) {
  459. _this.$message.info('请新增发货明细!')
  460. return false
  461. }
  462. if (_this.vaildGood('goodsName').indexOf(false) >= 0) {
  463. _this.$message.info('请选择物品!')
  464. return false
  465. }
  466. if (_this.vaildGood('goodsQty').indexOf(false) >= 0) {
  467. _this.$message.info('请输入件数!')
  468. return false
  469. }
  470. if (_this.vaildGood('totalAmount').indexOf(false) >= 0) {
  471. _this.$message.info('请输入费用!')
  472. return false
  473. }
  474. const baseUrl = this.isEdit ? sendBillUpdate : sendBillInsert
  475. _this.spinning = true
  476. baseUrl(_this.form).then(res => {
  477. if (res.status == 200) {
  478. _this.$emit('ok')
  479. _this.isShow = false
  480. _this.$message.success(res.message)
  481. }
  482. _this.spinning = false
  483. })
  484. } else {
  485. return false
  486. }
  487. })
  488. },
  489. // 取消
  490. handleCommonCancel () {
  491. this.$emit('cancel')
  492. this.tableData = []
  493. this.sendBillStockOutList = []
  494. this.spinning = false
  495. this.$refs.ruleForm.resetFields()
  496. this.form = {
  497. 'stockOutSnList': [], // 出库单列表
  498. 'sendDate': moment(), // 托运时间
  499. 'customerAddress': '', // 目的地
  500. 'customerAddressDetail': '', // 详细地址
  501. 'transportTele': '', // 物流电话
  502. 'transportNo': '', // 物流单号
  503. 'customerCacateName': '', // 收货人
  504. 'customerCacatePhone': '', // 收货人电话
  505. 'payType': '', // 收款方式
  506. 'handoverType': '', // 发货方式
  507. 'totalSendAmount': '', // 发货总费用
  508. 'sendBillDetailList': [] // 发货列表
  509. }
  510. }
  511. },
  512. watch: {
  513. // 父页面传过来的弹框状态
  514. openModal (newValue, oldValue) {
  515. this.isShow = newValue
  516. },
  517. // 重定义的弹框状态
  518. isShow (newValue, oldValue) {
  519. if (!newValue) {
  520. this.handleCommonCancel()
  521. }
  522. }
  523. }
  524. }
  525. </script>
  526. <style lang="less">
  527. .sendGood-detail-modal{
  528. .common-main{
  529. .toolsBar{
  530. padding-top:15px;
  531. border:1px solid #eee;
  532. border-radius: 3px;
  533. display: flex;
  534. align-items: center;
  535. margin-bottom: 10px;
  536. .ant-btn{
  537. margin-left: 30px;
  538. }
  539. }
  540. }
  541. .btn-box{
  542. text-align: center;
  543. margin-top: 30px;
  544. .ant-btn{
  545. margin:0 10px;
  546. }
  547. }
  548. }
  549. </style>