明晋仓库前台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PopupDistribution.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div>
  3. <el-dialog title="配车" :visible.sync="dialogVisible"
  4. width="1000px" height="400px" @close="close">
  5. <el-form :model="distribution" v-loading="dialoging"
  6. element-loading-text="拼命加载中"
  7. element-loading-spinner="el-icon-loading" label-width="100px" inline="">
  8. <el-form-item label="车号">
  9. <el-select v-model="truckNo" clearable allow-create filterable default-first-option @change="change" style="width: 200px;">
  10. <el-option v-for="item in trucks" :key="item.id" :label="item.truckNo" :value="item.truckNo">
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="司机姓名">
  15. <el-input v-model="distribution.driverName" placeholder="司机姓名" style="width: 200px;"></el-input>
  16. </el-form-item>
  17. <el-form-item label="联系方式">
  18. <el-input v-model="distribution.driverPhone" placeholder="联系方式" style="width: 200px;"></el-input>
  19. </el-form-item>
  20. <el-form-item label="总重量">
  21. <el-input v-model="sumWeight" placeholder="总重量" style="width: 200px;"></el-input>
  22. </el-form-item>
  23. <el-form-item label="总数量">
  24. <el-input v-model="sumCount" placeholder="总数量" style="width: 200px;"></el-input>
  25. </el-form-item>
  26. <el-form-item label="过磅重量" v-if="false">
  27. <el-input v-model="distribution.suttle" placeholder="过磅重量" style="width: 200px;"></el-input>
  28. </el-form-item>
  29. <el-form-item label="提货单位" >
  30. <el-input v-model="distribution.deliveryCompany" placeholder="提货单位" style="width: 200px;"></el-input>
  31. </el-form-item>
  32. <el-form-item label=" ">
  33. <el-button size="medium" type="success" @click="handleSave">确定</el-button>
  34. <el-button size="medium" type="success" @click="handleCancel">取消</el-button>
  35. <!-- <el-button size="medium" type="primary" @click="handlePrint">打印配车单</el-button> -->
  36. </el-form-item>
  37. </el-form>
  38. <el-table :data="tableData" border style="width: 99%;" ref="multipleTable" :row-class-name="tableRowClassName"
  39. @select="handleTableSelect" @select-all = "selectAll">
  40. <el-table-column type="selection" width="40" header-align="center" align="center">
  41. </el-table-column>
  42. <el-table-column prop="layer" label="层数" width="60" show-overflow-tooltip header-align="center" align="center">
  43. </el-table-column>
  44. <el-table-column prop="stack.name" label="垛位" width="60" show-overflow-tooltip header-align="center" align="center">
  45. </el-table-column>
  46. <el-table-column prop="material.name" label="物料" width="100" show-overflow-tooltip header-align="center" align="center">
  47. </el-table-column>
  48. <el-table-column prop="material.standard" label="钢种" width="100" show-overflow-tooltip header-align="center" align="center">
  49. </el-table-column>
  50. <el-table-column prop="plateNo" label="钢板号" width="200" show-overflow-tooltip header-align="center">
  51. </el-table-column>
  52. <el-table-column prop="model" label="规格型号" width="120" show-overflow-tooltip header-align="center" align="center">
  53. </el-table-column>
  54. <el-table-column prop="count" label="数量" width="120" show-overflow-tooltip align="right" header-align="center">
  55. </el-table-column>
  56. <el-table-column prop="weight" label="重量" width="120" show-overflow-tooltip align="right" header-align="center">
  57. </el-table-column>
  58. <el-table-column prop="customer.name" label="客户" width="300" show-overflow-tooltip header-align="center">
  59. </el-table-column>
  60. <el-table-column prop="receiveAddress" label="收货地址" width="300" show-overflow-tooltip header-align="center">
  61. </el-table-column>
  62. <el-table-column prop="wgtDcnMtcCd" label="计量方式" width="100" show-overflow-tooltip header-align="center">
  63. </el-table-column>
  64. <el-table-column prop="edgeTy" label="切边类型" width="100" show-overflow-tooltip header-align="center">
  65. </el-table-column>
  66. <el-table-column prop="productionPlace" label="产地" width="250" show-overflow-tooltip header-align="center">
  67. </el-table-column>
  68. </el-table>
  69. </el-dialog>
  70. </div>
  71. </template>
  72. <script>
  73. import axios from '@/axios';
  74. import {
  75. mapState
  76. } from 'vuex'
  77. export default {
  78. computed: {
  79. sumWeight: function() {
  80. let result = 0
  81. for (let i = 0; i < this.tableData.length; i++) {
  82. //console.log(this.distribution.listDetail[i].weight)
  83. result = Number(result) + Number(this.tableData[i].weight)
  84. }
  85. return result.toFixed(3)
  86. },
  87. sumCount: function() {
  88. let result = 0
  89. for (let i = 0; i < this.tableData.length; i++) {
  90. //console.log(this.distribution.listDetail[i].count)
  91. result = Number(result) + Number(this.tableData[i].count)
  92. }
  93. return result.toFixed(0)
  94. },
  95. ...mapState({
  96. serverName: state => state.app.serverName
  97. })
  98. },
  99. props: {
  100. selectRows: {
  101. type: Array
  102. },
  103. dialoging:{
  104. type:Boolean
  105. }
  106. },
  107. data() {
  108. return {
  109. trucks: [],
  110. truckNo: '',
  111. tableData: [],
  112. currentPage: 1,
  113. totalRows: 0,
  114. pageSizes: [10, 20, 30, 40],
  115. pageSize: 10,
  116. query: '',
  117. isShow: false,
  118. dialogVisible: false,
  119. dialoging: false,
  120. distribution: {
  121. truckNo: '',
  122. driverName: '',
  123. driverPhone: '',
  124. sumWeight: '',
  125. sumCount: '',
  126. suttle: '',
  127. deliveryCompany:'',
  128. listDetail: []
  129. },
  130. selection: []
  131. };
  132. },
  133. methods: {
  134. getTableData() {
  135. var url = 'MaintCustomer/query.do'
  136. var param = {
  137. page: this.currentPage,
  138. rows: this.pageSize,
  139. query: this.query
  140. }
  141. axios.get(url, param).then(response => {
  142. if (response.data.code == 0) {
  143. this.tableData = response.data.data.list
  144. this.totalRows = response.data.data.total
  145. } else {
  146. this.$message({
  147. type: 'error',
  148. message: '失败!' + response.data.msg,
  149. });
  150. }
  151. });
  152. },
  153. getTrucks() {
  154. var url = 'WareDistribution/queryWaitTrucks.do'
  155. var param = {}
  156. axios.get(url, param).then(response => {
  157. if (response.data.code == 0) {
  158. for (let i = 0; i < response.data.data.length; i++) {
  159. if (response.data.data.listDetail) {
  160. response.data.data.listDetail = []
  161. }
  162. }
  163. this.trucks = response.data.data
  164. // console.log(JSON.stringify(this.trucks))
  165. } else {
  166. this.$message({
  167. type: 'error',
  168. message: '失败!' + response.data.msg,
  169. });
  170. }
  171. });
  172. },
  173. // 修改每页行数
  174. handleSizeChange(val) {
  175. this.pageSize = val
  176. this.getTableData()
  177. },
  178. // 修改当前页事件
  179. handleCurrentChange(val) {
  180. this.currentPage = val
  181. this.getTableData()
  182. },
  183. sendToParent: function(row) {
  184. this.$emit('receviceFromChild', row);
  185. this.dialogVisible = false
  186. },
  187. show() {
  188. this.tableData = []
  189. this.distribution = {}
  190. this.dialogVisible = true
  191. //this.getTableData()
  192. this.getTrucks()
  193. //console.log(JSON.stringify(this.selectRows))
  194. for (let i = 0; i < this.selectRows.length; i++) {
  195. this.selectRows[i].lockFlag = '0'
  196. this.tableData.push(this.selectRows[i])
  197. }
  198. //this.tableData = this.tableData.concat()
  199. //console.log(JSON.stringify(this.selectRows))
  200. },
  201. search() {
  202. this.currentPage = 1
  203. this.getTableData()
  204. },
  205. clear() {
  206. this.distribution = {
  207. truckNo: '',
  208. driverName: '',
  209. driverPhone: '',
  210. sumWeight: this.sumWeight,
  211. sumCount: this.sumCount,
  212. suttle: '',
  213. listDetail: []
  214. }
  215. this.tableData = []
  216. },
  217. change(val) {
  218. if (val == '') {
  219. } else {
  220. for (let i = 0; i < this.trucks.length; i++) {
  221. if (this.trucks[i].truckNo == val) {
  222. this.distribution = this.trucks[i]
  223. }
  224. }
  225. this.tableData = []
  226. var tempPltNo = [];
  227. // console.log("iiiiiiiiii"+JSON.stringify(this.distribution))
  228. // if(typeof(this.distribution.listDetail) != "undefined"){
  229. // alert("kk")
  230. // }
  231. for (let i = 0; i < this.selectRows.length; i++) {
  232. this.tableData.push(this.selectRows[i])
  233. console.log(JSON.stringify(this.selectRows[i]))
  234. tempPltNo.push(this.selectRows[i].plateNo);
  235. }
  236. for (let i = 0; i < this.distribution.listDetail.length; i++) {
  237. // alert(JSON.stringify(this.distribution.listDetail[i].store))
  238. if(tempPltNo.indexOf(this.distribution.listDetail[i].store.plateNo) === -1){
  239. this.tableData.push(this.distribution.listDetail[i].store)
  240. }
  241. }
  242. this.distribution.sumWeight = this.sumWeight
  243. this.distribution.sumCount = this.sumCount
  244. this.truckNo = this.distribution.truckNo
  245. }
  246. },
  247. handleSave() {
  248. //console.log(JSON.stringify(this.distribution))
  249. this.dialoging = true
  250. this.distribution.sumWeight = this.sumWeight
  251. this.distribution.sumCount = this.sumCount
  252. this.distribution.truckNo = this.truckNo
  253. if(this.truckNo.length == 0){
  254. this.$message({
  255. type: 'error',
  256. message: '请选择车辆!'
  257. });
  258. return;
  259. }
  260. var url = 'WareDistribution/save.do'
  261. var param = {
  262. json: JSON.stringify(this.distribution),
  263. jsonList: JSON.stringify(this.selectRows)
  264. }
  265. axios.post(url, param).then(response => {
  266. if (response.data.code == 0) {
  267. this.dialoging = false
  268. this.dialogVisible = false
  269. this.selectRows = []
  270. } else {
  271. this.$message({
  272. type: 'error',
  273. message: '失败!' + response.data.msg,
  274. });
  275. this.dialoging = false
  276. }
  277. });
  278. },
  279. close() {
  280. this.distribution = {
  281. truckNo: '',
  282. driverName: '',
  283. driverPhone: '',
  284. sumWeight: 0,
  285. sumCount: 0,
  286. suttle: '',
  287. listDetail: []
  288. }
  289. this.tableData = []
  290. this.truckNo = ''
  291. this.$emit('receviceFromChild')
  292. },
  293. handlePrint() {
  294. if (this.distribution.truckNo == null || this.distribution.truckNo == '') {
  295. this.$message({
  296. type: 'error',
  297. message: '请选择车辆!'
  298. });
  299. return
  300. }
  301. // window.open(this.serverName + 'ureport/preview?_u=file:distribution.ureport.xml&id=' + this.distribution.id)
  302. window.open(this.serverName + 'ureport/preview?_u=file:distribution.ureport.xml&id=' + this.distribution.id)
  303. },
  304. handleTableSelect(selection, row) {
  305. if (row.lockFlag == '0') {
  306. this.$message({
  307. type: 'error',
  308. message: '该行未配货',
  309. });
  310. this.$refs.multipleTable.toggleRowSelection(row, false);
  311. } else {
  312. this.selection = selection
  313. }
  314. },
  315. selectAll(selection){
  316. for(var i = 0 ; i < selection.length;i++){
  317. if (selection[i].lockFlag == '0') {
  318. this.$message({
  319. type: 'error',
  320. message: '存在未配货记录',
  321. });
  322. return;
  323. }
  324. }
  325. this.selection = selection;
  326. },
  327. handleCancel() {
  328. var url = 'WareDistribution/cancel.do'
  329. if(this.selection.length == 0){
  330. this.$message({
  331. type: 'error',
  332. message: '请选择记录',
  333. });
  334. return;
  335. }
  336. var param = {
  337. json: JSON.stringify(this.distribution),
  338. jsonList: JSON.stringify(this.selection)
  339. }
  340. axios.post(url, param).then(response => {
  341. if (response.data.code == 0) {
  342. this.dialogVisible = false
  343. } else {
  344. this.$message({
  345. type: 'error',
  346. message: '失败!' + response.data.msg,
  347. });
  348. }
  349. });
  350. },
  351. tableRowClassName({
  352. row,
  353. rowIndex
  354. })
  355. {
  356. if (row.lockFlag == '1') {
  357. return 'success-row';
  358. }
  359. return '';
  360. }
  361. },
  362. }
  363. </script>
  364. <style>
  365. .el-table .success-row {
  366. background: #f0f9eb;
  367. }
  368. </style>