edit.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div>
  3. <el-button type="text" size="small" @click="onShow(drawer = true)">{{$t('编 辑')}}</el-button>
  4. <el-drawer
  5. :title="$t(`编辑装箱信息`)"
  6. :visible.sync="drawer"
  7. :with-header="false"
  8. append-to-body
  9. size="90%">
  10. <div class="drawer__panel">
  11. <p class="normal-title mt-10">
  12. {{$t(`装箱信息`)}}
  13. </p>
  14. <el-form style="width:500px" label-position="right" :label-width="tool.onlyZh('80px')" :model="form" size="small">
  15. <el-form-item :label="$t(`箱码`)">
  16. <el-input v-model="form.boxnum" :placeholder="$t(`输入箱码`)"></el-input>
  17. </el-form-item>
  18. <el-form-item :label="$t('备注')">
  19. <el-input type="textarea" :autosize="{minRows:5,maxRows:10}" v-model="form.remarks" :placeholder="$t(`请输入备注`)"></el-input>
  20. </el-form-item>
  21. </el-form>
  22. <p class="normal-title mt-10">
  23. {{$t(`装箱明细`)}}
  24. <el-button size="mini" type="text" @click="showSelect(setcol === 12 ? setcol = 24 : setcol = 12)">{{setcol === 24?$t('添加产品'):$t('关闭添加')}}</el-button>
  25. </p>
  26. <el-row :gutter="10">
  27. <el-col :span="setcol">
  28. <!-- 产品编码、产品名称、品号、型号、规格尺寸、装箱数量 -->
  29. <el-table
  30. :data="tableData"
  31. size="small"
  32. border>
  33. <el-table-column
  34. prop="billno"
  35. :label="$t(`发货单号`)"
  36. width="180">
  37. </el-table-column>
  38. <el-table-column
  39. prop="itemno"
  40. :label="$t(`产品编码`)"
  41. width="180">
  42. </el-table-column>
  43. <el-table-column
  44. prop="itemname"
  45. :label="$t('产品名称')"
  46. width="180">
  47. </el-table-column>
  48. <el-table-column
  49. prop="model"
  50. :label="$t('型号')"
  51. width="180">
  52. </el-table-column>
  53. <el-table-column
  54. prop="spec"
  55. :label="$t(`规格尺寸`)"
  56. width="180">
  57. </el-table-column>
  58. <el-table-column
  59. prop="qty"
  60. :label="$t(`装箱数量`)"
  61. width="200">
  62. <template slot-scope="scope">
  63. <el-input v-model.number="scope.row.qty" type="number" size="mini"></el-input>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. prop="remarks"
  68. :label="$t('备注')"
  69. min-width="250">
  70. <template slot-scope="scope">
  71. <el-input v-model="scope.row.remarks" size="mini"></el-input>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. :label="$t('操作')"
  76. fixed="right"
  77. width="90">
  78. <template slot-scope="scope">
  79. <el-button type="text" size="mini" @click="deleteRow(scope.row)">{{$t('删 除')}}</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. </el-col>
  84. <el-col :span="24 - setcol">
  85. <logisticsCanUseProduct ref="logislist" :sa_logistics_boxid="this.data.sa_logistics_boxid" @onConfirm="onConfirm" :addList="delList" type="edit">
  86. <el-button class="inline-16" slot="allBtn" type="primary" size="small" @click="handlePullData">{{$t(`一键全选`)}}</el-button>
  87. </logisticsCanUseProduct>
  88. </el-col>
  89. </el-row>
  90. </div>
  91. <div class="fixed__btn__panel">
  92. <el-button size="small" @click="drawer = false" class="normal-btn-width">{{$t('取 消')}}</el-button>
  93. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">{{$t(`保存修改`)}}</el-button>
  94. </div>
  95. </el-drawer>
  96. </div>
  97. </template>
  98. <script>
  99. import logisticsCanUseProduct from '@/template/logisticsCanUseProduct/index.vue'
  100. export default {
  101. props:['data'],
  102. data () {
  103. return {
  104. drawer:false,
  105. form:{},
  106. setcol:24,
  107. tableData:[],
  108. delList:[]
  109. }
  110. },
  111. components:{
  112. logisticsCanUseProduct
  113. },
  114. methods:{
  115. onShow () {
  116. this.form = Object.assign({},this.form,this.data)
  117. console.log(this.data,'data22222')
  118. this.delList = []
  119. this.listData()
  120. },
  121. async onSubmit (){
  122. let delID = []
  123. delID = this.delList.map(item=>item.sa_logistics_boxmxid)
  124. const res1 = await this.$api.requested({
  125. "id": "20230109155504",
  126. "content": {
  127. "sa_logisticsid":this.data.sa_logisticsid,
  128. "sa_logistics_boxmxids":delID
  129. }
  130. })
  131. if (res1.code == 0){
  132. this.tool.showMessage(res,()=>{})
  133. }
  134. const res = await this.$api.requested({
  135. "id": "20230109155104",
  136. "content": {
  137. "sa_logisticsid":this.$route.query.id,
  138. "sa_logistics_boxid": this.data.sa_logistics_boxid,
  139. "boxnum": this.form.boxnum,
  140. "remarks":this.form.remarks,
  141. "sa_logistics_boxmx": this.tableData.map(e=>{
  142. return {
  143. "sa_logistics_boxmxid": e.sa_logistics_boxmxid?e.sa_logistics_boxmxid:0,
  144. "sa_dispatch_itemsid": e.sa_dispatch_itemsid,
  145. "qty": e.qty,
  146. "remarks": e.remarks
  147. }
  148. })
  149. }
  150. })
  151. this.tool.showMessage(res,()=>{
  152. this.$emit('onSuccess')
  153. this.drawer = false
  154. })
  155. },
  156. showSelect () {
  157. this.$refs['logislist'].listData()
  158. },
  159. onConfirm (val) {
  160. this.tableData = [...val,...this.tableData]
  161. // const res = new Map();
  162. // this.tableData = this.tableData.filter((item) => !res.has(item['itemno']) && res.set(item['itemno'], 1));
  163. },
  164. async deleteRow (row) {
  165. this.tableData = this.tableData.filter(e=>{
  166. if (e.sa_dispatch_itemsid !== row.sa_dispatch_itemsid)
  167. return e
  168. })
  169. console.log(row,'row删除')
  170. let delNew = []
  171. delNew[0] = row
  172. this.delList = [...this.delList,...delNew]
  173. this.$refs.logislist.listData()
  174. },
  175. async handlePullData () {
  176. let res = await this.$api.requested({
  177. id:20230110112204,
  178. content: {
  179. "pageNumber": 1,
  180. "pageSize": 9999999999,
  181. "sa_logisticsid":this.$route.query.id,
  182. "sa_logistics_boxid":1,
  183. "where": {
  184. "condition": ""
  185. }
  186. }
  187. })
  188. if(res.data.length) {
  189. this.tableData = res.data
  190. // this.tableData.push(...res.data)
  191. // const res2 = new Map();
  192. // this.tableData = this.tableData.filter((item) => !res2.has(item['itemno']) && res2.set(item['itemno'], 1));
  193. this.$refs.logislist.tableData = []
  194. }
  195. },
  196. async listData (id) {
  197. const res = await this.$api.requested({
  198. "id": 20230109155304,
  199. "content": {
  200. "pageNumber": 1,
  201. "pageSize": 999,
  202. "sa_logisticsid":this.$route.query.id,
  203. "sa_logistics_boxid":this.data.sa_logistics_boxid,
  204. "where": {
  205. "condition": ""
  206. }
  207. }
  208. })
  209. this.tableData = res.data
  210. }
  211. }
  212. }
  213. </script>
  214. <style>
  215. </style>