_id.vue 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. <template>
  2. <div class="section">
  3. <div class="headline">
  4. <span>委托报关单详情</span>
  5. <div class="search_time">
  6. <a :href="'/clientPage/entrustApply?id=' + $route.params.id"><i class="el-icon-edit"></i>编 辑</a>
  7. </div>
  8. </div>
  9. <div class="entrust-apply">
  10. <el-form label-width="150px">
  11. <h4>深圳交货</h4>
  12. <el-row>
  13. <el-col :span="8">
  14. <el-form-item label="深圳交货方式">
  15. <span v-text="sheetInfo.deliveryType ? sheetInfo.deliveryType :'-'"/>
  16. </el-form-item>
  17. </el-col>
  18. </el-row>
  19. <template v-if="sheetInfo.deliveryContactInfo">
  20. <el-row>
  21. <el-col :span="8">
  22. <el-form-item label="收货人">
  23. <span v-text="sheetInfo.deliveryContactInfo ? JSON.parse(sheetInfo.deliveryContactInfo).name : '-'"/>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="联系方式">
  28. <span v-text="sheetInfo.deliveryContactInfo ? JSON.parse(sheetInfo.deliveryContactInfo).telephone : '-'"/>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. <el-row>
  33. <el-col :span="12">
  34. <el-form-item label="仓库/提货地址">
  35. <span v-text="sheetInfo.deliveryContactInfo ? JSON.parse(sheetInfo.deliveryContactInfo).detailAddress : '-'"/>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. </template>
  40. <h4>香港交货</h4>
  41. <el-row>
  42. <el-col :span="8">
  43. <el-form-item label="香港交货方式">
  44. <span v-text="sheetInfo.stockType ? sheetInfo.stockType :'-'"/>
  45. </el-form-item>
  46. </el-col>
  47. </el-row>
  48. <template v-if="sheetInfo.addressFileUrl">
  49. <upload placeholder="请上传香港交货单" @closeEvent="(e) => {return closeFile(e, 'addressFile')}" @uploadEvent="(e) => {return upload(e, 'addressFile')}" :fileData="sheetInfo.addressFileUrl"/>
  50. </template>
  51. <template v-if="!sheetInfo.addressFileUrl && sheetInfo.stockContactInfo">
  52. <el-row>
  53. <el-col :span="8">
  54. <el-form-item label="收货人">
  55. <span v-text="sheetInfo.stockContactInfo ? JSON.parse(sheetInfo.stockContactInfo).name : '-'"/>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="联系方式">
  60. <span v-text="sheetInfo.stockContactInfo ? JSON.parse(sheetInfo.stockContactInfo).telephone : '-'"/>
  61. </el-form-item>
  62. </el-col>
  63. </el-row>
  64. <el-row>
  65. <el-col :span="12">
  66. <el-form-item label="仓库/提货地址">
  67. <span v-text="sheetInfo.stockContactInfo ? JSON.parse(sheetInfo.stockContactInfo).detailAddress : '-'"/>
  68. </el-form-item>
  69. </el-col>
  70. </el-row>
  71. </template>
  72. <el-row>
  73. <el-col :span="24" v-if="sheetInfo.contactUrl">
  74. <el-form-item label="供应商合同">
  75. <a class="download" @click="downFileData(sheetInfo.contactUrl)"><i class="el-icon-download"></i></a>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="24" v-if="sheetInfo.billUrl">
  79. <el-form-item label="供应商发票">
  80. <a class="download" @click="downFileData(sheetInfo.billUrl)"><i class="el-icon-download"></i></a>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="24" v-if="sheetInfo.packagelistUrl">
  84. <el-form-item label="供应商箱单">
  85. <a class="download" @click="downFileData(sheetInfo.packagelistUrl)"><i class="el-icon-download"></i></a>
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. </el-form>
  90. <div style="overflow-x:auto;width:100%;" class="table-info">
  91. <table cellspacing="0" cellpadding="0">
  92. <thead>
  93. <tr>
  94. <th width="45">序号</th>
  95. <th width="120">商品名称</th>
  96. <th width="130">规格型号</th>
  97. <th width="75">数量(pcs)</th>
  98. <th width="75">箱数</th>
  99. <th width="75">净重(KG)</th>
  100. <th width="75">毛重(KG)</th>
  101. <th width="75">币种</th>
  102. <th width="75">单价</th>
  103. <th width="75">总价</th>
  104. <th width="80">品牌</th>
  105. <th width="85">产地</th>
  106. <th width="100">批次</th>
  107. <th width="75">备注</th>
  108. </tr>
  109. </thead>
  110. <tbody>
  111. <tr v-for="(item, index) in detailData">
  112. <td :class="{show: index === 0 || hasEdit}">
  113. <span v-text="index + 1"/>
  114. <div class="text-delete" @click="deleteRow(index)" v-if="index !== 0 && !hasEdit">
  115. <i class="el-icon-delete"/>
  116. </div>
  117. </td>
  118. <td :class="{err: item.errMsg.commodityName, is_select: item.isSelect.commodityName}">
  119. <template v-if="!item.dblclick.commodityName">
  120. <span v-text="item.commodityName"></span>
  121. </template>
  122. <template v-else>
  123. <input type="text" v-model="item.commodityName" :ref="'commodityName' + index" @blur="vaildCommodityName(index)" maxlength="100">
  124. </template>
  125. </td>
  126. <td :class="{err: item.errMsg.cmpCode, is_select: item.isSelect.cmpCode}">
  127. <template v-if="!item.dblclick.cmpCode">
  128. <span v-text="item.cmpCode"></span>
  129. </template>
  130. <template v-else>
  131. <input type="text" v-model="item.cmpCode" :ref="'cmpCode' + index" @blur="vaildCmpCode(index)" maxlength="100">
  132. </template>
  133. </td>
  134. <td :class="{err: item.errMsg.amount, is_select: item.isSelect.amount}">
  135. <template v-if="!item.dblclick.amount">
  136. <span v-text="item.amount"></span>
  137. </template>
  138. <template v-else>
  139. <input type="text" v-model.number.trim="item.amount" :ref="'amount' + index" @blur="vaildAmount(index)">
  140. </template>
  141. <div class="err-info" v-if="item.amountError">
  142. <i class="el-icon-question"/>
  143. <p v-text="item.amountErrorMessage">数量</p>
  144. </div>
  145. </td>
  146. <td v-if="item.show.cartonNum" :rowspan="item.rowspan.cartonNum" :class="{err: item.errMsg.cartonNum, is_select: item.isSelect.cartonNum}">
  147. <template v-if="!item.dblclick.cartonNum">
  148. <span v-text="item.cartonNum"></span>
  149. </template>
  150. <template v-else>
  151. <input type="text" v-model.number.trim="item.cartonNum" :ref="'cartonNum' + index" @blur="vaildCartonNum(index)">
  152. </template>
  153. <div class="err-info" v-if="item.cartonNumError">
  154. <i class="el-icon-question"/>
  155. <p v-text="item.cartonNumErrorMessage">商品名称</p>
  156. </div>
  157. </td>
  158. <td v-if="item.show.netWeight" :rowspan="item.rowspan.netWeight" :class="{err: item.errMsg.netWeight, is_select: item.isSelect.netWeight}">
  159. <template v-if="!item.dblclick.netWeight">
  160. <span v-text="item.netWeight"></span>
  161. </template>
  162. <template v-else>
  163. <input type="text" v-model.number.trim="item.netWeight" :ref="'netWeight' + index" @blur="vaildNetWeight(index)">
  164. </template>
  165. <div class="err-info" v-if="item.netWeightError">
  166. <i class="el-icon-question"/>
  167. <p v-text="item.netWeightErrorMessage">商品名称</p>
  168. </div>
  169. </td>
  170. <td v-if="item.show.grossWeight" :rowspan="item.rowspan.grossWeight" :class="{err: item.errMsg.grossWeight, is_select: item.isSelect.grossWeight}">
  171. <template v-if="!item.dblclick.grossWeight">
  172. <span v-text="item.grossWeight"></span>
  173. </template>
  174. <template v-else>
  175. <input type="text" v-model.number.trim="item.grossWeight" :ref="'grossWeight' + index" @blur="vaildGrossWeight(index)">
  176. </template>
  177. <div class="err-info" v-if="item.grossWeightError">
  178. <i class="el-icon-question"/>
  179. <p v-text="item.grossWeightErrorMessage">商品名称</p>
  180. </div>
  181. </td>
  182. <td :class="{err: item.errMsg.currency, is_select: item.isSelect.currency}">
  183. <template v-if="!item.dblclick.currency">
  184. <span v-text="item.currency"></span>
  185. </template>
  186. <template v-else>
  187. <input type="text" v-model.trim="item.currency" :ref="'currency' + index" @blur="vaildCurrency(index)">
  188. </template>
  189. <div class="err-info" v-if="item.currencyError">
  190. <i class="el-icon-question"/>
  191. <p v-text="item.currencyErrorMessage">商品名称</p>
  192. </div>
  193. </td>
  194. <td :class="{err: item.errMsg.unitPrice, is_select: item.isSelect.unitPrice}">
  195. <template v-if="!item.dblclick.unitPrice">
  196. <span v-text="item.unitPrice"></span>
  197. </template>
  198. <template v-else>
  199. <input type="text" v-model.number.trim="item.unitPrice" :ref="'unitPrice' + index" @blur="vaildUnitPrice(index)">
  200. </template>
  201. <div class="err-info" v-if="item.unitPriceError">
  202. <i class="el-icon-question"/>
  203. <p v-text="item.unitPriceErrorMessage">商品名称</p>
  204. </div>
  205. </td>
  206. <td :class="{err: item.errMsg.totalPrice, is_select: item.isSelect.totalPrice}">
  207. <template v-if="!item.dblclick.totalPrice">
  208. <span v-text="item.totalPrice"></span>
  209. </template>
  210. <template v-else>
  211. <input type="text" v-model.number.trim="item.totalPrice" :ref="'totalPrice' + index" @blur="vaildTotalPrice(index)">
  212. </template>
  213. <div class="err-info" v-if="item.totalPriceError">
  214. <i class="el-icon-question"/>
  215. <p v-text="item.totalPriceErrorMessage">商品名称</p>
  216. </div>
  217. </td>
  218. <td :class="{err: item.errMsg.brand, is_select: item.isSelect.brand}">
  219. <template v-if="!item.dblclick.brand">
  220. <span v-text="item.brand"></span>
  221. </template>
  222. <template v-else>
  223. <input type="text" v-model="item.brand" :ref="'brand' + index" @blur="vaildBrand(index)" maxlength="60">
  224. </template>
  225. <div class="err-info" v-if="item.brandError">
  226. <i class="el-icon-question"/>
  227. <p v-text="item.brandErrorMessage">商品名称</p>
  228. </div>
  229. </td>
  230. <td :class="{err: item.errMsg.producingArea, is_select: item.isSelect.producingArea}">
  231. <template v-if="!item.dblclick.producingArea">
  232. <span v-text="item.producingArea"></span>
  233. </template>
  234. <template v-else>
  235. <input type="text" v-model="item.producingArea" :ref="'producingArea' + index" @blur="vaildProducingArea(index)" maxlength="20">
  236. </template>
  237. <div class="err-info" v-if="item.producingAreaError">
  238. <i class="el-icon-question"/>
  239. <p v-text="item.producingAreaErrorMessage">商品名称</p>
  240. </div>
  241. </td>
  242. <td :class="{err: item.errMsg.batchNum, is_select: item.isSelect.batchNum}">
  243. <template v-if="!item.dblclick.batchNum">
  244. <span v-text="item.batchNum"></span>
  245. </template>
  246. <template v-else>
  247. <input type="text" v-model="item.batchNum" :ref="'batchNum' + index" @blur="vaildBatchNum(index)" maxlength="50">
  248. </template>
  249. <div class="err-info" v-if="item.batchNumError">
  250. <i class="el-icon-question"/>
  251. <p v-text="item.batchNumErrorMessage">商品名称</p>
  252. </div>
  253. </td>
  254. <td :class="{is_select: item.isSelect.remark}" :title="item.remark">
  255. <template v-if="!item.dblclick.remark">
  256. <span v-text="item.remark"></span>
  257. </template>
  258. <template v-else>
  259. <input type="text" v-model="item.remark" :ref="'remark' + index" @blur="vaildRemark(index)" maxlength="100">
  260. </template>
  261. </td>
  262. </tr>
  263. </tbody>
  264. </table>
  265. </div>
  266. </div>
  267. </div>
  268. </template>
  269. <script>
  270. import {Upload} from '@/components/common'
  271. export default {
  272. name: 'SheetDetailId',
  273. layout: 'default',
  274. middleware: 'authenticated',
  275. fetch({store, route}) {
  276. return Promise.all([
  277. store.dispatch('loadSheetDetails', {id: route.params.id})
  278. ])
  279. },
  280. components: {
  281. Upload
  282. },
  283. data () {
  284. return {
  285. hasEdit: false,
  286. tableData: {
  287. thead: [
  288. {id: 'index', name: '序号', type: 'String', width: 45},
  289. {id: 'commodityName', name: '商品名称', type: 'String', width: 117},
  290. {id: 'cmpCode', name: '规格型号', type: 'String', width: 129},
  291. {id: 'amount', name: '数量(pcs)', type: 'String', width: 100},
  292. {id: 'cartonNum', name: '箱数', type: 'String', width: 75},
  293. {id: 'netWeight', name: '净重(KG)', type: 'String', width: 75},
  294. {id: 'grossWeight', name: '毛重(KG)', type: 'String', width: 75},
  295. {id: 'currency', name: '币种', type: 'String', width: 75},
  296. {id: 'unitPrice', name: '单价', type: 'String', width: 98},
  297. {id: 'totalPrice', name: '总价', type: 'String', width: 98},
  298. {id: 'brand', name: '品牌', type: 'String', width: 80},
  299. {id: 'producingArea', name: '产地', type: 'String', width: 90},
  300. {id: 'batchNum', name: '批次', type: 'String', width: 115},
  301. {id: 'remark', name: '备注', type: 'String', width: 75},
  302. ],
  303. attr: [
  304. {id: 'errMsg', default: false},
  305. {id: 'isSelect', default: false},
  306. {id: 'show', default: true},
  307. {id: 'dblclick', default: false},
  308. {id: 'rowspan', default: 1},
  309. {id: 'splitData', default: ''}],
  310. filters: ['cartonNum', 'netWeight', 'grossWeight']
  311. },
  312. rowspan: [],
  313. fileList: {},
  314. detailData: []
  315. }
  316. },
  317. mounted () {
  318. this.$nextTick(() => {
  319. this.clearSheet()
  320. })
  321. },
  322. computed: {
  323. sheetInfo () {
  324. return this.$store.state.clientSheet.details.data.content
  325. }
  326. },
  327. methods: {
  328. // 下载文件信息
  329. downFileData (type) {
  330. window.open(type)
  331. },
  332. // 数据增加属性
  333. addAttrData (type) {
  334. let list = type
  335. for (let i = 0; i < list.length; i++) {
  336. for (let j = 0; j < this.tableData.attr.length; j++) {
  337. let _n = {}
  338. for (let k = 0; k < this.tableData.thead.length; k++) {
  339. if (this.tableData.attr[j].id === 'splitData') {
  340. _n[this.tableData.thead[k].id] = `${this.tableData.thead[k].id}_${i}_${i}`
  341. } else {
  342. _n[this.tableData.thead[k].id] = this.tableData.attr[j].default
  343. }
  344. }
  345. list[i][this.tableData.attr[j].id] = _n
  346. }
  347. }
  348. return list
  349. },
  350. // 识别返回数据存在的合并情况进行处理
  351. getSplitData (data, arr) {
  352. arr.forEach((value) => {
  353. let _m = []
  354. for (let i = 1; i < data.length; i++) {
  355. if (data[i][value] === -1) {
  356. _m.push(data[i].splitData[value])
  357. }
  358. }
  359. let counts = []
  360. if (_m.length > 0) {
  361. let count = {state: Number(_m[0].split('_')[1]), num: 1}
  362. for (let j = 1; j < _m.length; j++) {
  363. if (_m[j].split('_')[1] - _m[j - 1].split('_')[1] == 1) {
  364. count.num++
  365. } else {
  366. counts.push(count)
  367. count = {state: Number(_m[j].split('_')[1]), num: 1}
  368. }
  369. }
  370. counts.push(count)
  371. for(let k = 0; k < counts.length; k++) {
  372. let star = counts[k].state
  373. for (let n = 0; n < counts[k].num; n++) {
  374. data[star - 1].rowspan[value] = counts[k].num + 1
  375. data[star + n].show[value] = false
  376. data[star + n].splitData[value] = `${value}_${star + n - 1}_${star + counts[k].num - 1}`
  377. data[star - 1].splitData[value] = `${value}_${star - 1}_${star + counts[k].num - 1}`
  378. }
  379. }
  380. }
  381. })
  382. },
  383. // 清空数据
  384. clearSheet () {
  385. this.rowspan = []
  386. this.detailData = JSON.parse(JSON.stringify(this.sheetInfo.commissionSheetDetail)).sort((a, b) => {
  387. return a.detno > b.detno
  388. })
  389. this.getSplitData(this.addAttrData(this.detailData), this.tableData.filters)
  390. },
  391. // 删除指定行
  392. deleteRow (type) {
  393. let del = true
  394. let rowMax = this.form.commissionSheetDetail.length
  395. let rowData = this.form.commissionSheetDetail[type]
  396. for (let i = 0; i < this.tableData.thead.length; i++) {
  397. if (rowData.splitData[this.tableData.thead[i].id].split('_')[1] !== rowData.splitData[this.tableData.thead[i].id].split('_')[2]) {
  398. this.$message({
  399. message: '删除行不能存在合并的单元格,请先拆分!',
  400. type: 'error'
  401. })
  402. del = false
  403. break
  404. }
  405. }
  406. del ? this.form.commissionSheetDetail.splice(type, 1) : ''
  407. for (let k = 0; k < this.tableData.thead.length; k++) {
  408. for (let j = type; j < rowMax - 1; j++) {
  409. let _m = this.form.commissionSheetDetail[j].splitData
  410. _m[this.tableData.thead[k].id] = `${this.tableData.thead[k].id}_${Number(_m[this.tableData.thead[k].id].split('_')[1]) - 1}_${Number(_m[this.tableData.thead[k].id].split('_')[2]) - 1}`
  411. }
  412. }
  413. },
  414. // 合并表格
  415. mergeTd () {
  416. for(let i = 0; i < this.rowspan.length -1; i++) {
  417. if (this.rowspan[i].split('_')[0] !== this.rowspan[i+1].split('_')[0]) {
  418. this.$message({
  419. type: 'error',
  420. message: '合并失败,不能横向进行合并!'
  421. })
  422. return
  423. } else if (this.rowspan[i].split('_')[0] !== 'cartonNum' && this.rowspan[i].split('_')[0] !== 'netWeight' && this.rowspan[i].split('_')[0] !== 'grossWeight') {
  424. this.$message({
  425. type: 'error',
  426. message: '只能对箱数、净重、毛重进行合并!'
  427. })
  428. return
  429. }
  430. }
  431. this.rowspan.sort((a, b) => {return a.split('_')[2] - b.split('_')[2]})
  432. let minRow = this.rowspan[0]
  433. let maxRow = this.rowspan[this.rowspan.length-1]
  434. if (this.rowspan.length < 2) {
  435. this.$message({
  436. type: 'error',
  437. message: '必须含两个选择单元格!'
  438. })
  439. } else if ((maxRow.split('_')[2] - minRow.split('_')[2] + 1) !== this.rowspan.length) {
  440. this.$message({
  441. type: 'error',
  442. message: '选择单元格必须是连续的!'
  443. })
  444. } else {
  445. this.form.commissionSheetDetail[minRow.split('_')[1]].rowspan[minRow.split('_')[0]] = this.rowspan.length
  446. for(let j = Number(minRow.split('_')[1]); j <= Number(maxRow.split('_')[2]); j++) {
  447. this.form.commissionSheetDetail[j].splitData[minRow.split('_')[0]] = `${minRow.split('_')[0]}_${minRow.split('_')[1]}_${maxRow.split('_')[1]}`
  448. this.form.commissionSheetDetail[Number(minRow.split('_')[1])].isSelect[minRow.split('_')[0]] = false
  449. if (j !== Number(minRow.split('_')[1])) {
  450. this.form.commissionSheetDetail[j].show[minRow.split('_')[0]] = false
  451. this.form.commissionSheetDetail[j].isSelect[minRow.split('_')[0]] = false
  452. this.form.commissionSheetDetail[j][minRow.split('_')[0]] = -1
  453. }
  454. }
  455. this.rowspan = []
  456. }
  457. },
  458. // 拆分表格
  459. splitTd () {
  460. if (this.rowspan.length > 0 && this.rowspan.length === 1 && (this.rowspan[0].split('_')[1] !== this.rowspan[0].split('_')[2])) {
  461. let rowMin = Number(this.rowspan[0].split('_')[1])
  462. let rowMax = Number(this.rowspan[0].split('_')[2])
  463. let name = this.rowspan[0].split('_')[0]
  464. this.form.commissionSheetDetail[rowMin].rowspan[name] = 1
  465. for (let i = rowMin; i <= rowMax; i++) {
  466. this.form.commissionSheetDetail[i].isSelect[name] = false
  467. this.form.commissionSheetDetail[i].splitData[name] = `${name}_${i}_${i}`
  468. if (i !== rowMin) {
  469. this.form.commissionSheetDetail[i].rowspan[name] = 1
  470. this.form.commissionSheetDetail[i].show[name] = true
  471. this.form.commissionSheetDetail[i][name] = 0
  472. }
  473. }
  474. this.rowspan = []
  475. } else {
  476. this.$message({
  477. type: 'error',
  478. message: '请选择一个合并过的单元格!'
  479. })
  480. }
  481. },
  482. // 表格增加一行
  483. addTable () {
  484. let _arr = {
  485. detno: '',
  486. commodityName: '',
  487. cmpCode: '',
  488. amount: '',
  489. cartonNum: '',
  490. netWeight: '',
  491. grossWeight: '',
  492. currency: '',
  493. unitPrice: '',
  494. totalPrice: '',
  495. brand: '',
  496. producingArea: '',
  497. batchNum: '',
  498. remark: ''
  499. }
  500. for (let j = 0; j < this.tableData.attr.length; j++) {
  501. let _n = {}
  502. for (let k = 0; k < this.tableData.thead.length; k++) {
  503. if (this.tableData.attr[j].id === 'splitData') {
  504. _n[this.tableData.thead[k].id] = `${this.tableData.thead[k].id}_${this.form.commissionSheetDetail.length}_${this.form.commissionSheetDetail.length}`
  505. } else {
  506. _n[this.tableData.thead[k].id] = this.tableData.attr[j].default
  507. }
  508. }
  509. _arr[this.tableData.attr[j].id] = _n
  510. }
  511. this.form.commissionSheetDetail.push(_arr)
  512. },
  513. // 单元格单击
  514. cellClick (key, name) {
  515. this.form.commissionSheetDetail[key].isSelect[name] = !this.form.commissionSheetDetail[key].isSelect[name]
  516. if (this.rowspan.length === 0) {
  517. this.rowspan.push(this.form.commissionSheetDetail[key].splitData[name])
  518. } else {
  519. for(let index = 0; index < this.rowspan.length; index++) {
  520. if (this.rowspan[index].split('_')[1] === key.toString() && this.rowspan[index].split('_')[0] === name) {
  521. if (this.form.commissionSheetDetail[key].isSelect[name] === false) {
  522. this.rowspan.splice(index, 1)
  523. break
  524. }
  525. } else {
  526. if (this.form.commissionSheetDetail[key].isSelect[name] === true) {
  527. this.rowspan.push(this.form.commissionSheetDetail[key].splitData[name])
  528. break
  529. }
  530. }
  531. }
  532. }
  533. },
  534. // 表格双击
  535. dblclick (name, key) {
  536. this.form.commissionSheetDetail[key].dblclick[name] = !this.form.commissionSheetDetail[key].dblclick[name]
  537. this.form.commissionSheetDetail[key].isSelect[name] = false
  538. this.$nextTick (()=> {
  539. this.$refs[name + key + ''][0].focus()
  540. })
  541. },
  542. // 上传成功后的回调
  543. uploadSuccess (res, file, fileList) {
  544. console.log(file, fileList)
  545. if (res.success) {
  546. this.$message({
  547. message: '文件上传成功',
  548. type: 'success'
  549. })
  550. } else {
  551. this.$message.error(res.message)
  552. }
  553. },
  554. // 上传错误
  555. uploadError (res, file, fileList) {
  556. console.log(file, fileList)
  557. this.$message.error('上传失败,请重新上传文件!')
  558. },
  559. // 选择文件,对文件内容打包处理
  560. selectFile (file) {
  561. this.form.deliveryFileUrl = file.name
  562. this.fileList.push(file)
  563. },
  564. // 验证手机号
  565. checkTel (rule, value, callback) {
  566. if (!value) {
  567. return callback(new Error('联系方式不能为空'))
  568. } else {
  569. let reg = /^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\D])|(18[0,5-9]))\d{8}$/
  570. if (!(reg.test(value))) {
  571. callback(new Error('请输入正确的手机号'))
  572. } else {
  573. callback()
  574. }
  575. }
  576. },
  577. // 验证商品名称
  578. vaildCommodityName (type) {
  579. this.form.commissionSheetDetail[type].dblclick.commodityName = false
  580. this.form.commissionSheetDetail[type].isSelect.commodityName = false
  581. if (this.form.commissionSheetDetail[type].commodityName == '') {
  582. this.form.commissionSheetDetail[type].errMsg.commodityName = true
  583. this.$message({
  584. message: '请填写' + (type + 1) + '行商品名称内容,不能为空!',
  585. type: 'warning'
  586. })
  587. } else {
  588. this.form.commissionSheetDetail[type].errMsg.commodityName = false
  589. }
  590. },
  591. // 验证规格型号
  592. vaildCmpCode (type) {
  593. this.form.commissionSheetDetail[type].dblclick.cmpCode = false
  594. this.form.commissionSheetDetail[type].isSelect.cmpCode = false
  595. let reg = /[\u4E00-\u9FA5\uf900-\ufa2d]/
  596. if (this.form.commissionSheetDetail[type].cmpCode == '') {
  597. this.form.commissionSheetDetail[type].errMsg.cmpCode = true
  598. this.$message({
  599. message: '请填写序号' + (type + 1) + '行商品规格型号内容,不能为空!',
  600. type: 'warning'
  601. })
  602. } else if (reg.test(this.form.commissionSheetDetail[type].cmpCode)) {
  603. this.form.commissionSheetDetail[type].errMsg.cmpCode = true
  604. this.$message({
  605. message: '请注意序号' + (type + 1) + '行商品规格型号内容,不能含中文字符!',
  606. type: 'warning'
  607. })
  608. } else {
  609. this.form.commissionSheetDetail[type].errMsg.cmpCode = false
  610. }
  611. },
  612. // 验证数量
  613. vaildAmount (type) {
  614. this.form.commissionSheetDetail[type].dblclick.amount = false
  615. this.form.commissionSheetDetail[type].isSelect.amount = false
  616. let reg = /^[1-9]([0-9])*$/
  617. if (this.form.commissionSheetDetail[type].amount == '') {
  618. this.form.commissionSheetDetail[type].errMsg.amount = true
  619. this.$message({
  620. message: '请填写序号' + (type + 1) + '行商品数量内容,不能为空!',
  621. type: 'warning'
  622. })
  623. } else if (!reg.test(this.form.commissionSheetDetail[type].amount)) {
  624. this.form.commissionSheetDetail[type].errMsg.amount = true
  625. this.$message({
  626. message: '请填写序号' + (type + 1) + '行商品数量内容,必须是正整数!',
  627. type: 'warning'
  628. })
  629. } else {
  630. this.form.commissionSheetDetail[type].errMsg.amount = false
  631. }
  632. },
  633. // 验证箱数
  634. vaildCartonNum (type) {
  635. this.form.commissionSheetDetail[type].dblclick.cartonNum = false
  636. this.form.commissionSheetDetail[type].isSelect.cartonNum = false
  637. let reg = /(^[1-9]([0-9])*$)|(^(-1){1}$)/
  638. if (this.form.commissionSheetDetail[type].cartonNum == '') {
  639. this.form.commissionSheetDetail[type].errMsg.cartonNum = true
  640. this.$message({
  641. message: '请填写序号' + (type + 1) + '行箱数内容,不能为空!',
  642. type: 'warning'
  643. })
  644. } else if (!reg.test(this.form.commissionSheetDetail[type].cartonNum)) {
  645. this.form.commissionSheetDetail[type].errMsg.cartonNum = true
  646. this.$message({
  647. message: '请填写序号' + (type + 1) + '行箱数内容为正整数。为*号表示向下合并单元格!',
  648. type: 'warning'
  649. })
  650. } else {
  651. this.vaildNetWeight(type)
  652. this.vaildGrossWeight(type)
  653. this.form.commissionSheetDetail[type].errMsg.cartonNum = false
  654. }
  655. },
  656. // 验证净重
  657. vaildNetWeight (type) {
  658. this.form.commissionSheetDetail[type].dblclick.netWeight = false
  659. this.form.commissionSheetDetail[type].isSelect.netWeight = false
  660. let reg = /(^[0-9]+(\.[0-9]{1,2})?$)|(^(-1){1}$)/
  661. if (this.form.commissionSheetDetail[type].netWeight == '') {
  662. this.form.commissionSheetDetail[type].errMsg.netWeight = true
  663. this.$message({
  664. message: '请填写序号' + (type + 1) + '行净重内容,不能为空!',
  665. type: 'warning'
  666. })
  667. } else {
  668. if (this.form.commissionSheetDetail[type].netWeight == '*' && (this.form.commissionSheetDetail[type].cartonNum != '*' || this.form.commissionSheetDetail[type].grossWeight != '*')) {
  669. this.form.commissionSheetDetail[type].errMsg.netWeight = true
  670. this.$message({
  671. message: '请填写序号' + (type + 1) + '行净重内容有误,净重合并的情况必须毛重和箱数都要合并,请确认!',
  672. type: 'warning'
  673. })
  674. } else if (!reg.test(this.form.commissionSheetDetail[type].netWeight)) {
  675. this.form.commissionSheetDetail[type].errMsg.netWeight = true
  676. this.$message({
  677. message: '请填写序号' + (type + 1) + '行净重内容只保留两位有效数值!',
  678. type: 'warning'
  679. })
  680. } else {
  681. this.form.commissionSheetDetail[type].errMsg.netWeight = false
  682. }
  683. }
  684. },
  685. // 验证毛重
  686. vaildGrossWeight (type) {
  687. this.form.commissionSheetDetail[type].dblclick.grossWeight = false
  688. this.form.commissionSheetDetail[type].isSelect.grossWeight = false
  689. let reg = /(^[0-9]+(\.[0-9]{1,2})?$)|(^(-1){1}$)/
  690. if (this.form.commissionSheetDetail[type].grossWeight == '') {
  691. this.form.commissionSheetDetail[type].errMsg.grossWeight = true
  692. this.$message({
  693. message: '请填写序号' + (type + 1) + '行毛重内容,不能为空!',
  694. type: 'warning'
  695. })
  696. } else {
  697. if (this.form.commissionSheetDetail[type].cartonNum != '*' && this.form.commissionSheetDetail[type].grossWeight == '*') {
  698. this.form.commissionSheetDetail[type].errMsg.grossWeight = true
  699. this.$message({
  700. message: '请填写序号' + (type + 1) + '行毛重内容有误,毛重合并的情况箱数必须合并,请确认!',
  701. type: 'warning'
  702. })
  703. } else if (!reg.test(this.form.commissionSheetDetail[type].grossWeight)) {
  704. this.form.commissionSheetDetail[type].errMsg.grossWeight = true
  705. this.$message({
  706. message: '请填写序号' + (type + 1) + '行毛重内容只保留两位有效数值!',
  707. type: 'warning'
  708. })
  709. } else {
  710. this.vaildNetWeight(type)
  711. this.form.commissionSheetDetail[type].errMsg.grossWeight = false
  712. }
  713. }
  714. },
  715. // 验证币种
  716. vaildCurrency (type) {
  717. this.form.commissionSheetDetail[type].dblclick.currency = false
  718. this.form.commissionSheetDetail[type].isSelect.currency = false
  719. if (this.form.commissionSheetDetail[type].currency == '') {
  720. this.form.commissionSheetDetail[type].errMsg.currency = true
  721. this.$message({
  722. message: '请填写序号' + (type + 1) + '行币种内容,不能为空!',
  723. type: 'warning'
  724. })
  725. } else {
  726. this.form.commissionSheetDetail[type].errMsg.currency = false
  727. }
  728. },
  729. // 验证单价
  730. vaildUnitPrice (type) {
  731. this.form.commissionSheetDetail[type].dblclick.unitPrice = false
  732. this.form.commissionSheetDetail[type].isSelect.unitPrice = false
  733. let reg = /^\d*\.?\d{0,4}$/
  734. if (this.form.commissionSheetDetail[type].unitPrice == '') {
  735. this.form.commissionSheetDetail[type].errMsg.unitPrice = true
  736. this.$message({
  737. message: '请填写序号' + (type + 1) + '行单价内容,不能为空!',
  738. type: 'warning'
  739. })
  740. } else if (!reg.test(this.form.commissionSheetDetail[type].unitPrice)) {
  741. this.form.commissionSheetDetail[type].errMsg.unitPrice = true
  742. this.$message({
  743. message: '请填写序号' + (type + 1) + '行单价内容只保留四位有效数值!',
  744. type: 'warning'
  745. })
  746. } else {
  747. this.form.commissionSheetDetail[type].errMsg.unitPrice = false
  748. }
  749. },
  750. // 验证总价
  751. vaildTotalPrice (type) {
  752. this.form.commissionSheetDetail[type].dblclick.totalPrice = false
  753. this.form.commissionSheetDetail[type].isSelect.totalPrice = false
  754. if (this.form.commissionSheetDetail[type].amount && this.form.commissionSheetDetail[type].unitPrice) {
  755. this.form.commissionSheetDetail[type].totalPrice = this.form.commissionSheetDetail[type].amount * this.form.commissionSheetDetail[type].unitPrice
  756. let reg = /^\d*\.?\d{0,4}$/
  757. if (this.form.commissionSheetDetail[type].totalPrice == '') {
  758. this.form.commissionSheetDetail[type].errMsg.totalPrice = true
  759. this.$message({
  760. message: '请填写序号' + (type + 1) + '行总价内容,不能为空!',
  761. type: 'warning'
  762. })
  763. } else if (!reg.test(this.form.commissionSheetDetail[type].totalPrice)) {
  764. this.form.commissionSheetDetail[type].errMsg.totalPrice = true
  765. this.$message({
  766. message: '请填写序号' + (type + 1) + '行总价内容只保留四位有效数值!',
  767. type: 'warning'
  768. })
  769. } else {
  770. this.form.commissionSheetDetail[type].errMsg.totalPrice = false
  771. }
  772. }
  773. },
  774. // 验证品牌
  775. vaildBrand (type) {
  776. this.form.commissionSheetDetail[type].dblclick.brand = false
  777. this.form.commissionSheetDetail[type].isSelect.brand = false
  778. if (this.form.commissionSheetDetail[type].brand == '') {
  779. this.form.commissionSheetDetail[type].errMsg.brand = true
  780. this.$message({
  781. message: '请填写序号' + (type + 1) + '行品牌内容,不能为空!',
  782. type: 'warning'
  783. })
  784. } else {
  785. this.form.commissionSheetDetail[type].errMsg.brand = false
  786. }
  787. },
  788. // 验证产地
  789. vaildProducingArea (type) {
  790. this.form.commissionSheetDetail[type].dblclick.producingArea = false
  791. this.form.commissionSheetDetail[type].isSelect.producingArea = false
  792. if (this.form.commissionSheetDetail[type].producingArea == '') {
  793. this.form.commissionSheetDetail[type].errMsg.producingArea = true
  794. this.$message({
  795. message: '请填写序号' + (type + 1) + '行产地内容,不能为空!',
  796. type: 'warning'
  797. })
  798. } else {
  799. this.form.commissionSheetDetail[type].errMsg.producingArea = false
  800. }
  801. },
  802. // 验证批次
  803. vaildBatchNum (type) {
  804. this.form.commissionSheetDetail[type].dblclick.batchNum = false
  805. this.form.commissionSheetDetail[type].isSelect.batchNum = false
  806. if (this.form.commissionSheetDetail[type].batchNum == '') {
  807. this.form.commissionSheetDetail[type].errMsg.batchNum = true
  808. this.$message({
  809. message: '请填写序号' + (type + 1) + '行批次内容,不能为空!',
  810. type: 'warning'
  811. })
  812. } else {
  813. this.form.commissionSheetDetail[type].errMsg.batchNum = false
  814. }
  815. },
  816. // 验证备注信息
  817. vaildRemark (type) {
  818. this.form.commissionSheetDetail[type].dblclick.remark = false
  819. this.form.commissionSheetDetail[type].isSelect.remark = false
  820. },
  821. // 取消清空内容信息
  822. submitCancel (type) {
  823. this.$refs[type].clearValidate()
  824. this.clearSheet()
  825. },
  826. // 保存客户填写表单信息
  827. submitSave (type) {
  828. this.$refs[type].validate((valid) => {
  829. if (!valid) {
  830. this.$message({
  831. message: '请正确填写上面的信息,确认无误!',
  832. type: 'warning'
  833. })
  834. return false
  835. } else {
  836. let list = this.form.commissionSheetDetail
  837. for (let key of list.keys()) {
  838. this.vaildGrossWeight(key)
  839. this.vaildNetWeight(key)
  840. this.vaildCartonNum(key)
  841. this.vaildAmount(key)
  842. this.vaildBatchNum(key)
  843. this.vaildBrand(key)
  844. this.vaildCmpCode(key)
  845. this.vaildCommodityName(key)
  846. this.vaildCurrency(key)
  847. this.vaildProducingArea(key)
  848. this.vaildUnitPrice(key)
  849. }
  850. for(let i of list.values()) {
  851. if (i.errMsg.commodityName == true ||
  852. i.errMsg.amount == true ||
  853. i.errMsg.batchNum == true ||
  854. i.errMsg.brand == true ||
  855. i.errMsg.cartonNum == true ||
  856. i.errMsg.cmpCode == true ||
  857. i.errMsg.commodityName == true ||
  858. i.errMsg.currency == true ||
  859. i.errMsg.grossWeight == true ||
  860. i.errMsg.netWeight == true ||
  861. i.errMsg.producingArea == true ||
  862. i.errMsg.unitPrice == true ||
  863. i.errMsg.remark == true) {
  864. this.$message({
  865. message: '请正确填写上面的信息,确认无误!',
  866. type: 'warning'
  867. })
  868. return false
  869. }
  870. }
  871. for(let i of list.values()) {
  872. i.grossWeight == '*' ? i.grossWeight = null : i.grossWeight = Number(i.grossWeight)
  873. i.netWeight == '*' ? i.netWeight = null : i.netWeight = Number(i.netWeight)
  874. i.cartonNum == '*' ? i.cartonNum = null : i.cartonNum = Number(i.cartonNum)
  875. i.amount == '*' ? i.amount = null : i.amount = Number(i.amount)
  876. i.unitPrice = Number(i.unitPrice)
  877. i.totalPrice = Number(i.totalPrice)
  878. }
  879. this.form.commissionSheetDetail = list
  880. let params = new FormData()
  881. params.append('file' , this.fileList)
  882. params.append('params' , JSON.stringify(this.form))
  883. let config = {
  884. headers: {'Content-Type': 'multipart/form-data'}
  885. }
  886. this.$http.post('/CommissionSheet/save', params, config)
  887. .then(response => {
  888. if (response.data.success) {
  889. this.$message({
  890. message: '报关申请提交成功',
  891. type: 'success'
  892. })
  893. this.$router.push('/clientPage/' + response.data.content.id)
  894. } else {
  895. this.$message({
  896. message: response.data.message,
  897. type: 'warning'
  898. })
  899. this.$router.push('/clientPage/entrustApply/' + response.data.content.id)
  900. }
  901. }).catch(() => {
  902. this.$message.error( '请检查网络,提交失败!')
  903. })
  904. }
  905. })
  906. }
  907. }
  908. }
  909. </script>
  910. <style lang="scss" type="text/scss" scoped>
  911. .entrust-apply{
  912. padding:0 15px;
  913. margin-bottom:100px;
  914. h4{
  915. color:#0d5ffe;
  916. font-size: 14px;
  917. margin: 20 auto;
  918. }
  919. .el-form-item {
  920. position:relative;
  921. margin:0;
  922. .el-select{
  923. width:100%;
  924. }
  925. .input-title{
  926. position:absolute;
  927. top:0;
  928. right:-20px;
  929. &:hover{
  930. cursor:pointer;
  931. span{
  932. display: inline-block;
  933. width: 400px;
  934. line-height: 40px;
  935. z-index: 20000;
  936. position: absolute;
  937. left:25px;
  938. }
  939. }
  940. span{
  941. display:none;
  942. }
  943. }
  944. }
  945. .el-form-item__label{
  946. color:#333;
  947. }
  948. hr{
  949. border:2px dashed #eaeaea;
  950. margin: 25px auto;
  951. }
  952. .download{
  953. font-size: 16px;
  954. font-weight: bold;
  955. text-align: center;
  956. }
  957. .table-info{
  958. padding-top:30px;
  959. table{
  960. width:100%;
  961. table-layout: fixed;
  962. margin-bottom:20px;
  963. border-collapse: unset;
  964. border-spacing: 0;
  965. th{
  966. border: 1px solid #eee;
  967. line-height: 46px;
  968. background: #deeffe;
  969. }
  970. td{
  971. &.err{
  972. border:1px solid red;
  973. }
  974. &.is_select{
  975. background: #f0f7fe;
  976. color:#0d5ffe;
  977. }
  978. border: 1px solid #eee;
  979. text-align: center;
  980. word-break: break-all;
  981. word-wrap: break-word;
  982. vertical-align: middle;
  983. height:44px;
  984. position:relative;
  985. span{
  986. line-height: 18px;
  987. }
  988. &:first-child:hover{
  989. cursor:pointer;
  990. span{
  991. display:none;
  992. }
  993. .text-delete{
  994. display:block;
  995. }
  996. }
  997. &.show:hover{
  998. cursor:default;
  999. span{
  1000. display:block;
  1001. }
  1002. }
  1003. .text-delete{
  1004. display:none;
  1005. position:absolute;
  1006. top:0;
  1007. left:0;
  1008. width:40px;
  1009. height:40px;
  1010. line-height: 40px;
  1011. text-align: center;
  1012. i{
  1013. font-size: 18px;
  1014. font-weight: bold;
  1015. }
  1016. }
  1017. .err-info{
  1018. position:absolute;
  1019. display:inline-block;
  1020. width:15px;
  1021. height:15px;
  1022. top:0;
  1023. right:0;
  1024. &:hover{
  1025. cursor:pointer;
  1026. p{
  1027. display:block;
  1028. }
  1029. }
  1030. i{
  1031. color:red;
  1032. font-size: 16px;
  1033. vertical-align:top;
  1034. }
  1035. p{
  1036. position: absolute;
  1037. display: none;
  1038. width: 160px;
  1039. height: 50px;
  1040. line-height: 20px;
  1041. background: #fff;
  1042. bottom: -50%;
  1043. right: 20px;
  1044. z-index: 20000;
  1045. box-shadow: 0 0 5px rgba(0,0,0,.7);
  1046. font-size: 12px;
  1047. text-align: left;
  1048. color:#333;
  1049. padding-left:3px;
  1050. overflow-y: auto;
  1051. }
  1052. }
  1053. input{
  1054. width:100%;
  1055. font-size: 16px;
  1056. line-height: 40px;
  1057. border:none;
  1058. margin:0;
  1059. padding-left:5px;
  1060. }
  1061. }
  1062. }
  1063. }
  1064. .form-btn{
  1065. margin-left:150px;
  1066. padding-top:55px;
  1067. }
  1068. }
  1069. </style>