|
|
@@ -1,66 +1,169 @@
|
|
|
-// package-base-select/pages/select-source-sale-order/select-source-sale-order.js
|
|
|
+const Constants = require('@/utils/Constants.js');
|
|
|
+const util = require('@/utils/util.js')
|
|
|
+const mixins = require('@/mixins/index.js')
|
|
|
Page({
|
|
|
+ mixins: [mixins],
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ returnTotalAmount: 0,
|
|
|
+ allChecked: false,
|
|
|
+ // 路由
|
|
|
+ routeObjName: 'inbound',
|
|
|
+ tableData: [],
|
|
|
+ choooseInboundItemList: [],
|
|
|
+ buttonSaveList: [{ code: 'add', title: mixins.$t('confirm'), width: '120rpx', color: '#1B365D' }],
|
|
|
+ contentSaveList: [{code:'flag',title:'全出',type:'checkbox'},{code:'need',title:'合计金额',type:'str'},{code:'amount',content:0,type:'number'}],
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 加载数据源
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ getData(params) {
|
|
|
+ return this.excute(this.data.service, this.data.service.selectInboundAndItem, params);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 设置查询参数
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ setSearchParams(params) {
|
|
|
+ params.intoType = Constants.intoType.pur
|
|
|
+ params.fromId = this.data.id
|
|
|
+ return params
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 父级商品信息选择
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ onListItemChange(e) {
|
|
|
+ let tableData = this.data.tableData
|
|
|
+ let index = e.currentTarget.dataset.index
|
|
|
+ tableData[index].checked = !tableData[index].checked
|
|
|
+ let inboundItemList = tableData[index].inboundItemList
|
|
|
+ if (inboundItemList && inboundItemList.length > 0) {
|
|
|
+ inboundItemList.forEach(res => {
|
|
|
+ res.checked = tableData[index].checked
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 页面的初始数据
|
|
|
- */
|
|
|
- data: {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
- */
|
|
|
- onLoad(options) {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
- */
|
|
|
- onReady() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面隐藏
|
|
|
- */
|
|
|
- onHide() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
- */
|
|
|
- onUnload() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
- */
|
|
|
- onPullDownRefresh() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom() {
|
|
|
+ this.setData({
|
|
|
+ tableData: tableData
|
|
|
+ })
|
|
|
+ this.calculateTotal()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 子级商品信息选择
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ onChangeItemCheckbox(e) {
|
|
|
+ let tableData = this.data.tableData
|
|
|
+ let index = e.currentTarget.dataset.index
|
|
|
+ let index_ = e.currentTarget.dataset.index_
|
|
|
+ console.log(index, index_)
|
|
|
+ tableData[index].inboundItemList[index_].checked = !tableData[index].inboundItemList[index_].checked
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ tableData: tableData
|
|
|
+ })
|
|
|
+
|
|
|
+ this.calculateTotal()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 全退
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ onCheckboxChange(e) {
|
|
|
+ console.log(e.detail.checked)
|
|
|
+ let checked = e.detail.checked
|
|
|
+ let tableData = this.data.tableData
|
|
|
+ tableData.forEach(res => {
|
|
|
+ res.checked = checked
|
|
|
+ if (res.inboundItemList && res.inboundItemList.length > 0) {
|
|
|
+ res.inboundItemList.forEach(item => {
|
|
|
+ item.checked = checked
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ tableData: tableData
|
|
|
+ })
|
|
|
+ this.calculateTotal()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 计算金额/过滤出已选数据
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ calculateTotal() {
|
|
|
+ let tableData = this.data.tableData
|
|
|
+ let contentSaveList = this.data.contentSaveList
|
|
|
+ let choooseInboundItemList = []
|
|
|
+ let returnTotalAmount = Number(0)
|
|
|
+ //过滤出已选数据
|
|
|
+ tableData.forEach(res => {
|
|
|
+ if (res.inboundItemList && res.inboundItemList.length > 0) {
|
|
|
+ res.inboundItemList.forEach(item => {
|
|
|
+ if (item.checked) {
|
|
|
+ item.itemQty = Number(item.rejectQty * -1)
|
|
|
+ item.itemQtyMax = Number(item.rejectQty * -1)
|
|
|
+ item.priceReturn = Number(item.priceInto * -1)
|
|
|
+ item.itemAmt = Number(item.rejectQty * item.priceInto * -1)
|
|
|
+ choooseInboundItemList.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (choooseInboundItemList && choooseInboundItemList.length > 0) {
|
|
|
+ choooseInboundItemList.forEach(res => {
|
|
|
+ returnTotalAmount += Number(res.rejectQty * res.priceInto)
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ contentSaveList[2]['content'] = returnTotalAmount.toFixed(2)
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ choooseInboundItemList: choooseInboundItemList,
|
|
|
+ contentSaveList: contentSaveList,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @desc : 跳转退货页
|
|
|
+ * @date : 2024/2/1 15:49
|
|
|
+ * @author : 于继渤
|
|
|
+ */
|
|
|
+ toAdd() {
|
|
|
+ let choooseInboundItemList = this.data.choooseInboundItemList
|
|
|
+ let that = this
|
|
|
+ let formData = that.data.formData
|
|
|
+ let item = that.data.item
|
|
|
+ wx.navigateTo({
|
|
|
+ url: this.data.route.addReturn.url,
|
|
|
+ success: function (res) {
|
|
|
+ res.eventChannel.emit('params', {
|
|
|
+ formMode:'add',
|
|
|
+ choooseInboundItemList: choooseInboundItemList,
|
|
|
+ goodsRejectedAmount: that.data.returnTotalAmount,
|
|
|
+ item: JSON.stringify(item)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
- /**
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage() {
|
|
|
|
|
|
- }
|
|
|
})
|