weighing.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <div class="center">
  3. <el-row>
  4. <el-col :span="12">
  5. <h2 class="bg-left titleup">{{ information }}检斤信息</h2>
  6. </el-col>
  7. <el-col :span="12" class="bg-right">
  8. <el-button class="bg-bottom" type="primary" size="small" @click="cancel"><img width="6" height="10"
  9. style="vertical-align: bottom; margin-right: 3px" src="../../../public/img/lujing.png"
  10. alt="" />返回</el-button>
  11. </el-col>
  12. </el-row>
  13. <div class="substance">
  14. <ws-form>
  15. <div style="width: 50%; margin: 0 auto">
  16. <div class="title">基本信息</div>
  17. <ws-info-table>
  18. <ws-form-item label="合同编号" span="1">
  19. <ws-select v-model="weighingList.contractNo" @change="contractChange" maxlength="100"
  20. :disabled="disabled1" size="small">
  21. <ws-option v-for="item in contractNoList" :key="item.contractNo"
  22. :label="item.contractNo" :value="item.contractNo" />
  23. </ws-select>
  24. </ws-form-item>
  25. <ws-form-item label="仓位号" span="1" prop="binNumber">
  26. <ws-select v-model="weighingList.binNumber" class="typeselect" :disabled="disabled">
  27. <ws-option v-for="item in getbinNumberList" :key="item.value" :label="item.value"
  28. :value="item.value" />
  29. </ws-select>
  30. </ws-form-item>
  31. <ws-form-item label="货名" span="1" prop="goodsName">
  32. <ws-input v-model="weighingList.goodsName" placeholder="请输入货名" maxlength="100" disabled
  33. size="small" />
  34. </ws-form-item>
  35. <ws-form-item label="囤位号" span="1" prop="storageNumber">
  36. <ws-input v-model="weighingList.storageNumber" placeholder="请输入囤位号" maxlength="100"
  37. size="small" :disabled="disabled" />
  38. </ws-form-item>
  39. <ws-form-item label="车牌号" span="1" prop="carNumber">
  40. <ws-input v-model="weighingList.carNumber" placeholder="请输入车牌号" maxlength="100" size="small"
  41. :disabled="disabled" />
  42. </ws-form-item>
  43. <ws-form-item label="出库类型" span="1" prop="inOutType">
  44. <ws-select v-model="weighingList.inOutType" :disabled="disabled">
  45. <ws-option v-for="item in inOutType" :key="item.value" :label="item.value"
  46. :value="item.value" />
  47. </ws-select>
  48. </ws-form-item>
  49. <ws-form-item label="毛重(公斤)" span="1" prop="grossWeight" v-if="this.types == 1">
  50. <ws-input v-model="weighingList.grossWeight" @input="calculation" placeholder="未获取到毛重"
  51. maxlength="100" size="small" :disabled="disabled2" />
  52. </ws-form-item>
  53. <el-button type="primary" v-if="this.types == 1" @click="chongxin">重新获取</el-button>
  54. <ws-form-item label="皮重(公斤)" span="1" prop="tare">
  55. <ws-input v-model="weighingList.tare" placeholder="未获取到皮重" maxlength="100" size="small"
  56. disabled />
  57. </ws-form-item>
  58. <el-button type="primary" v-if="this.types == 2 || this.types == null">重新获取</el-button>
  59. <!-- <div class="formItem"> -->
  60. <ws-form-item label="净重(公斤)" span="1" prop="netWeight" v-if="this.types == 1">
  61. <ws-input v-model="weighingList.netWeight" placeholder="请输入净重" maxlength="100" size="small"
  62. disabled />
  63. </ws-form-item>
  64. <!-- </div> -->
  65. <div class="bangdan">
  66. <el-form-item label="上传磅单" v-if="this.types == 1">
  67. </el-form-item>
  68. <el-upload action="https://www.zthymaoyi.com/upload/admin" list-type="picture-card"
  69. :on-success="(res, file) => {handlePictureCardPreview1(res)}"
  70. :on-remove="(value) => {handleRemove(value)}" class="photo2" v-if="this.types == 1">
  71. <i class="el-icon-plus"></i>
  72. </el-upload>
  73. <el-dialog :visible.sync="dialogVisible" v-if="this.types == 1">
  74. <img width="100%" :src="weighingList.addressUrl" alt="" />
  75. </el-dialog>
  76. </div>
  77. </ws-info-table>
  78. <div class="but">
  79. <el-button @click="cancel" type="primary">取消</el-button>
  80. <el-button @click="print" type="primary">保存</el-button>
  81. </div>
  82. </div>
  83. </ws-form>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import {
  89. grossWeight,
  90. getbinNumber,
  91. contractList,
  92. tareAdd,
  93. tareEdit,
  94. getweighing
  95. } from '@/model/outboundManagement/index'
  96. export default {
  97. data() {
  98. return {
  99. inspect: {},
  100. types: 3,
  101. information: '添加皮重',
  102. weighingList: {
  103. carNumber: '',
  104. storageNumber: '',
  105. buckleMiscellaneous: 0,
  106. compId: sessionStorage.getItem('ws-pf_compId'),
  107. },
  108. disabled: false,
  109. disabled1: false,
  110. disabled2: false,
  111. dialogVisible: false,
  112. getbinNumberList: [],
  113. warehouseName: '',
  114. contractNoList: [],
  115. inOutType: [{
  116. value: '销售出库',
  117. type: 1
  118. },
  119. {
  120. value: '移库出库',
  121. type: 3
  122. },
  123. {
  124. value: '暂存出库',
  125. type: 5
  126. },
  127. {
  128. value: '贸易服务出库',
  129. type: 7
  130. },
  131. ],
  132. relationId: '',
  133. warehouseId: '', //仓库id
  134. }
  135. },
  136. activated() {
  137. this.types = this.$route.query.typeNo
  138. this.weighingList.number = this.$route.query.number
  139. this.weighingList.binNumber = this.$route.query.binNumber
  140. this.weighingList.storageNumber = this.$route.query.storageNumber
  141. this.weighingList.carNumber = this.$route.query.carNumber
  142. this.weighingList.goodsName = this.$route.query.goodsName
  143. this.weighingList.inOutType = this.$route.query.inOutType
  144. this.warehouseName = this.$route.query.warehouseName
  145. let id = this.$route.query.id
  146. this.relationId = this.$route.query.relationId
  147. this.warehouseId = this.$route.query.warehouseId
  148. if (this.types == 1) {
  149. this.information = '毛重'
  150. this.disabled = true
  151. this.disabled1 = true
  152. } else if (this.types == 2) {
  153. this.information = '编辑皮重'
  154. this.disabled1 = true
  155. this.disabled2 = true
  156. }
  157. this.getList(id)
  158. },
  159. methods: {
  160. chongxin() {
  161. if (this.types == 2 || this.types == 3) {
  162. return
  163. }
  164. },
  165. handlePictureCardPreview1(file) {
  166. this.weighingList.addressUrl += file.url + ','
  167. this.addressUrls.push(file.url)
  168. },
  169. cancel() {
  170. this.weighingList = {}
  171. this.$router.push({
  172. path: 'weighingManagement'
  173. })
  174. },
  175. calculation() {
  176. if (this.weighingList.grossWeight && this.weighingList.tare) {
  177. let count = 0
  178. this.weighingList.netWeight =
  179. this.weighingList.grossWeight -
  180. this.weighingList.tare
  181. }
  182. },
  183. contractChange(e) {
  184. for (let i = 0; i < this.contractNoList.length; i++) {
  185. if (e == this.contractNoList[i].contractNo) {
  186. this.weighingList.goodsName = this.contractNoList[i].goodsName
  187. this.weighingList.contractPrice = this.contractNoList[i].contractPrice
  188. }
  189. }
  190. },
  191. getList() {
  192. if (this.types == 2 || this.types == 1) {
  193. getweighing({
  194. id: this.$route.query.id
  195. })
  196. .toPromise()
  197. .then((response) => {
  198. this.weighingList = response
  199. })
  200. }
  201. // 仓位
  202. getbinNumber({
  203. id: this.warehouseId
  204. })
  205. .toPromise()
  206. .then((response) => {
  207. this.getbinNumberList = []
  208. for (let i = 0; i < response.warehousePositionInfoList.length; i++) {
  209. this.getbinNumberList.push({
  210. value: response.warehousePositionInfoList[i].binNumber,
  211. })
  212. }
  213. })
  214. //合同编号
  215. contractList({
  216. compId: sessionStorage.getItem('ws-pf_compId'),
  217. flag: 5
  218. })
  219. .toPromise()
  220. .then((response) => {
  221. this.contractNoList = response
  222. })
  223. },
  224. print() {
  225. if (this.types == null || this.types == 2) {
  226. if (!this.weighingList.contractNo) {
  227. this.$message({
  228. message: '合同编号不能为空',
  229. type: 'warning',
  230. })
  231. return
  232. }
  233. if (!this.weighingList.binNumber) {
  234. this.$message({
  235. message: '仓位号不能为空',
  236. type: 'warning',
  237. })
  238. return
  239. }
  240. if (!this.weighingList.storageNumber) {
  241. this.$message({
  242. message: '囤位号不能为空',
  243. type: 'warning',
  244. })
  245. return
  246. }
  247. if (
  248. this.weighingList.storageNumber.length < 1 ||
  249. this.weighingList.storageNumber.length > 10
  250. ) {
  251. this.$message({
  252. message: '囤位号不超过10个字符!',
  253. type: 'warning',
  254. })
  255. return
  256. }
  257. if (!this.weighingList.carNumber) {
  258. this.$message({
  259. message: '车牌号不能为空',
  260. type: 'warning',
  261. })
  262. return
  263. }
  264. if (
  265. this.weighingList.carNumber.length != 7
  266. ) {
  267. this.$message({
  268. message: '车牌号输入错误',
  269. type: 'warning',
  270. })
  271. return
  272. }
  273. if (!this.weighingList.inOutType) {
  274. this.$message({
  275. message: '出库类型不能为空',
  276. type: 'warning',
  277. })
  278. return
  279. }
  280. // if (!this.weighingList.tare) {
  281. // this.$message({
  282. // message: '皮重不能为空',
  283. // type: 'warning',
  284. // })
  285. // return
  286. // }
  287. // if (
  288. // isNaN(this.weighingList.tare) ||
  289. // (String(this.weighingList.tare).indexOf('.') != -1 &&
  290. // String(this.weighingList.tare).length -
  291. // (String(this.weighingList.tare).indexOf('.') + 1) >
  292. // 1) ||
  293. // this.weighingList.tare < 1 ||
  294. // this.weighingList.tare > 100000
  295. // ) {
  296. // this.$message({
  297. // message: '皮重输入错误!',
  298. // type: 'warning',
  299. // })
  300. // return
  301. // }
  302. }
  303. if (this.types == 1) {
  304. if (!this.weighingList.grossWeight) {
  305. this.$message({
  306. message: '毛重不能为空',
  307. type: 'warning',
  308. })
  309. return
  310. }
  311. if (
  312. isNaN(this.weighingList.grossWeight) ||
  313. (String(this.weighingList.grossWeight).indexOf('.') != -1 &&
  314. String(this.weighingList.grossWeight).length -
  315. (String(this.weighingList.grossWeight).indexOf('.') + 1) >
  316. 1) ||
  317. this.weighingList.grossWeight < 1 ||
  318. this.weighingList.grossWeight > 100000
  319. ) {
  320. this.$message({
  321. message: '毛重输入错误!',
  322. type: 'warning',
  323. })
  324. return
  325. }
  326. }
  327. this.weighingList.warehouseName = this.warehouseName
  328. this.weighingList.secretaryWeigher = sessionStorage.getItem('ws-pf_staffName')
  329. this.$confirm('确定保存检斤信息?', '提示', {
  330. confirmButtonText: '确定',
  331. cancelButtonText: '取消',
  332. type: 'warning',
  333. })
  334. .then(() => {
  335. if (this.types == 1) {
  336. this.weighingList.relationId = this.relationId
  337. grossWeight(this.weighingList)
  338. .toPromise()
  339. .then((response) => {
  340. this.$notify.success({
  341. title: '成功',
  342. message: '提交成功',
  343. })
  344. this.$router.push({
  345. path: 'weighingManagement'
  346. })
  347. })
  348. .catch((response) => {})
  349. } else if (this.types == 2) {
  350. this.weighingList.warehouseId = this.warehouseId
  351. tareEdit(this.weighingList)
  352. .toPromise()
  353. .then((response) => {
  354. this.$notify.success({
  355. title: '成功',
  356. message: '提交成功',
  357. })
  358. this.$router.push({
  359. path: 'weighingManagement'
  360. })
  361. })
  362. .catch((response) => {})
  363. } else if (this.types == null) {
  364. this.weighingList.warehouseId = this.warehouseId
  365. tareAdd(this.weighingList)
  366. .toPromise()
  367. .then((response) => {
  368. this.$notify.success({
  369. title: '成功',
  370. message: '提交成功',
  371. })
  372. this.$router.push({
  373. path: 'weighingManagement'
  374. })
  375. })
  376. .catch((response) => {})
  377. }
  378. })
  379. .catch(() => {
  380. return false
  381. })
  382. },
  383. },
  384. }
  385. </script>
  386. <style lang="scss" scoped>
  387. .center {
  388. background: #f6f7fc;
  389. }
  390. .ws-info-table {
  391. border: none;
  392. }
  393. .ws-info-table .el-form-item {
  394. width: 50%;
  395. border: none;
  396. }
  397. .formItem {
  398. width: 100%;
  399. display: inline;
  400. }
  401. /deep/.ws-info-table .el-form-item .el-form-item__label {
  402. width: 30%;
  403. text-align: center;
  404. background: #ffffff;
  405. font-size: 14px;
  406. color: #8890b1;
  407. }
  408. /deep/.ws-info-table .el-form-item .el-form-item__content {
  409. border: none;
  410. }
  411. .title {
  412. font-size: 16px;
  413. font-weight: 600;
  414. margin: 10px;
  415. }
  416. .titleup {
  417. position: relative;
  418. }
  419. .title::before {
  420. content: '';
  421. display: inline-block;
  422. width: 5px;
  423. height: 15px;
  424. background: #8890b1;
  425. margin-right: 5px;
  426. }
  427. .substance {
  428. background: #ffffff;
  429. width: 100%;
  430. border-radius: 4px;
  431. margin: 0 auto;
  432. padding-top: 20px;
  433. }
  434. /deep/.el-table .el-table__header .cell,
  435. .el-table .el-table__body .cell {
  436. text-align: center;
  437. }
  438. /deep/.el-table--enable-row-transition .el-table__body td {
  439. text-align: center;
  440. }
  441. .bg-left {
  442. padding-left: 30px;
  443. }
  444. .bg-right {
  445. padding-right: 10px;
  446. text-align: right;
  447. }
  448. .bg-bottom {
  449. margin: 15px 0px;
  450. }
  451. .titleup {
  452. position: relative;
  453. }
  454. /deep/ .substance .bangdan {
  455. width: 100%;
  456. padding-top: 6%;
  457. padding-bottom: 6%;
  458. }
  459. // // .photo2{
  460. // // margin-top: 10px;
  461. // // }
  462. .el-upload--picture-card {
  463. background-color: #fbfdff;
  464. border: 1px dashed #c0ccda;
  465. border-radius: 6px;
  466. box-sizing: border-box;
  467. width: 148px;
  468. height: 148px;
  469. line-height: 146px;
  470. vertical-align: top;
  471. margin-left: -289px;
  472. }
  473. .titleup::before {
  474. content: '';
  475. display: inline-block;
  476. width: 5px;
  477. height: 30px;
  478. background: #5473e8;
  479. position: absolute;
  480. left: 0;
  481. }
  482. .but {
  483. text-align: center;
  484. margin: 20px auto;
  485. }
  486. .butCss {
  487. opacity: 0;
  488. }
  489. </style>