_id.vue 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. <template>
  2. <div class="section">
  3. <div class="headline">
  4. <span>委托报关单详情</span>
  5. <div class="search_time">
  6. <a :href="'/severPage/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. <tempalte v-if="sheetInfo.deliveryContactInfoSimplify">
  20. <el-row >
  21. <el-col :span="8">
  22. <el-form-item label="收货人">
  23. <span v-text="sheetInfo.deliveryContactInfoSimplify ? JSON.parse(sheetInfo.deliveryContactInfoSimplify).name : '-'"/>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="联系方式">
  28. <span v-text="sheetInfo.deliveryContactInfoSimplify ? JSON.parse(sheetInfo.deliveryContactInfoSimplify).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.deliveryContactInfoSimplify ? JSON.parse(sheetInfo.deliveryContactInfoSimplify).detailAddress : '-'"/>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. </tempalte>
  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.stockContactInfoSimplify">
  52. <el-row>
  53. <el-col :span="8">
  54. <el-form-item label="收货人">
  55. <span v-text="sheetInfo.stockContactInfoSimplify ? JSON.parse(sheetInfo.stockContactInfoSimplify).name : '-'"/>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="联系方式">
  60. <span v-text="sheetInfo.stockContactInfoSimplify ? JSON.parse(sheetInfo.stockContactInfoSimplify).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.stockContactInfoSimplify ? JSON.parse(sheetInfo.stockContactInfoSimplify).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" @dblclick="dialogClick(item.id)" :class="{errmsg : errInfo[item.id]}">
  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.commodityNameSimplify"></span>
  121. </template>
  122. <template v-else>
  123. <input type="text" v-model="item.commodityNameSimplify" :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.producingAreaSimplify"></span>
  233. </template>
  234. <template v-else>
  235. <input type="text" v-model="item.producingAreaSimplify" :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.remarkSimplify"></span>
  257. </template>
  258. <template v-else>
  259. <input type="text" v-model="item.remarkSimplify" :ref="'remark' + index" @blur="vaildRemark(index)" maxlength="100">
  260. </template>
  261. </td>
  262. </tr>
  263. </tbody>
  264. </table>
  265. </div>
  266. <buts :err-msg="errInfo"/>
  267. <el-dialog
  268. title="错误描述"
  269. :visible.sync="hasDialog"
  270. width="30%">
  271. <div><el-input type="textarea" v-model="errInfo[hasPcs]" placeholder="请在这里填写错误描述信息!"/></div>
  272. <div slot="footer" class="dialog-footer">
  273. <el-button @click="hasDialog = false">取 消</el-button>
  274. <el-button type="primary" @click="deleteErr">删 除</el-button>
  275. <el-button type="success" @click="saveErr">保 存</el-button>
  276. </div>
  277. </el-dialog>
  278. </div>
  279. </div>
  280. </template>
  281. <script>
  282. import {Buts, Upload} from '@/components/common'
  283. export default {
  284. name: 'EntrustDetailId',
  285. layout: 'default',
  286. middleware: 'authenticated',
  287. fetch({store, route}) {
  288. return Promise.all([
  289. store.dispatch('loadSheetDetails', {id: route.params.id})
  290. ])
  291. },
  292. components: {
  293. Buts,
  294. Upload
  295. },
  296. data () {
  297. return {
  298. hasDialog: false,
  299. hasPcs: '',
  300. errInfo: {},
  301. hasEdit: false,
  302. tableData: {
  303. thead: [
  304. {id: 'index', name: '序号', type: 'String', width: 45},
  305. {id: 'commodityName', name: '商品名称', type: 'String', width: 117},
  306. {id: 'cmpCode', name: '规格型号', type: 'String', width: 129},
  307. {id: 'amount', name: '数量(pcs)', type: 'String', width: 100},
  308. {id: 'cartonNum', name: '箱数', type: 'String', width: 75},
  309. {id: 'netWeight', name: '净重(KG)', type: 'String', width: 75},
  310. {id: 'grossWeight', name: '毛重(KG)', type: 'String', width: 75},
  311. {id: 'currency', name: '币种', type: 'String', width: 75},
  312. {id: 'unitPrice', name: '单价', type: 'String', width: 98},
  313. {id: 'totalPrice', name: '总价', type: 'String', width: 98},
  314. {id: 'brand', name: '品牌', type: 'String', width: 80},
  315. {id: 'producingArea', name: '产地', type: 'String', width: 90},
  316. {id: 'batchNum', name: '批次', type: 'String', width: 115},
  317. {id: 'remark', name: '备注', type: 'String', width: 75},
  318. ],
  319. attr: [
  320. {id: 'errMsg', default: false},
  321. {id: 'isSelect', default: false},
  322. {id: 'show', default: true},
  323. {id: 'dblclick', default: false},
  324. {id: 'rowspan', default: 1},
  325. {id: 'splitData', default: ''}],
  326. filters: ['cartonNum', 'netWeight', 'grossWeight']
  327. },
  328. rowspan: [],
  329. fileList: {},
  330. detailData: []
  331. }
  332. },
  333. mounted () {
  334. this.$nextTick(() => {
  335. this.clearSheet()
  336. })
  337. },
  338. computed: {
  339. sheetInfo () {
  340. return this.$store.state.severSheet.details.data.content
  341. }
  342. },
  343. methods: {
  344. // 下载文件信息
  345. downFileData (type) {
  346. window.open(type)
  347. },
  348. // 指定错误行信息
  349. dialogClick (type) {
  350. this.hasDialog = true
  351. this.hasPcs = type
  352. },
  353. // 删除错误信息
  354. deleteErr () {
  355. delete this.errInfo[this.hasPcs]
  356. this.hasDialog = false
  357. },
  358. // 保存错误信息
  359. saveErr () {
  360. this.errInfo[this.hasPcs] = this.errInfo[this.hasPcs]
  361. this.hasDialog = false
  362. },
  363. // 获取仓储部分返回的错误信息
  364. getErr (type) {
  365. this.errMsg = type
  366. },
  367. // 数据增加属性
  368. addAttrData (type) {
  369. let list = type
  370. for (let i = 0; i < list.length; i++) {
  371. for (let j = 0; j < this.tableData.attr.length; j++) {
  372. let _n = {}
  373. for (let k = 0; k < this.tableData.thead.length; k++) {
  374. if (this.tableData.attr[j].id === 'splitData') {
  375. _n[this.tableData.thead[k].id] = `${this.tableData.thead[k].id}_${i}_${i}`
  376. } else {
  377. _n[this.tableData.thead[k].id] = this.tableData.attr[j].default
  378. }
  379. }
  380. list[i][this.tableData.attr[j].id] = _n
  381. }
  382. }
  383. return list
  384. },
  385. // 识别返回数据存在的合并情况进行处理
  386. getSplitData (data, arr) {
  387. arr.forEach((value) => {
  388. let _m = []
  389. for (let i = 1; i < data.length; i++) {
  390. if (data[i][value] === -1) {
  391. _m.push(data[i].splitData[value])
  392. }
  393. }
  394. let counts = []
  395. if (_m.length > 0) {
  396. let count = {state: Number(_m[0].split('_')[1]), num: 1}
  397. for (let j = 1; j < _m.length; j++) {
  398. if (_m[j].split('_')[1] - _m[j - 1].split('_')[1] == 1) {
  399. count.num++
  400. } else {
  401. counts.push(count)
  402. count = {state: Number(_m[j].split('_')[1]), num: 1}
  403. }
  404. }
  405. counts.push(count)
  406. for(let k = 0; k < counts.length; k++) {
  407. let star = counts[k].state
  408. for (let n = 0; n < counts[k].num; n++) {
  409. data[star - 1].rowspan[value] = counts[k].num + 1
  410. data[star + n].show[value] = false
  411. data[star + n].splitData[value] = `${value}_${star + n - 1}_${star + counts[k].num - 1}`
  412. data[star - 1].splitData[value] = `${value}_${star - 1}_${star + counts[k].num - 1}`
  413. }
  414. }
  415. }
  416. })
  417. },
  418. // 清空数据
  419. clearSheet () {
  420. this.rowspan = []
  421. this.detailData = JSON.parse(JSON.stringify(this.sheetInfo.commissionSheetDetail)).sort((a, b) => {
  422. return a.detno > b.detno
  423. })
  424. this.getSplitData(this.addAttrData(this.detailData), this.tableData.filters)
  425. },
  426. // 删除指定行
  427. deleteRow (type) {
  428. let del = true
  429. let rowMax = this.form.commissionSheetDetail.length
  430. let rowData = this.form.commissionSheetDetail[type]
  431. for (let i = 0; i < this.tableData.thead.length; i++) {
  432. if (rowData.splitData[this.tableData.thead[i].id].split('_')[1] !== rowData.splitData[this.tableData.thead[i].id].split('_')[2]) {
  433. this.$message({
  434. message: '删除行不能存在合并的单元格,请先拆分!',
  435. type: 'error'
  436. })
  437. del = false
  438. break
  439. }
  440. }
  441. del ? this.form.commissionSheetDetail.splice(type, 1) : ''
  442. for (let k = 0; k < this.tableData.thead.length; k++) {
  443. for (let j = type; j < rowMax - 1; j++) {
  444. let _m = this.form.commissionSheetDetail[j].splitData
  445. _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}`
  446. }
  447. }
  448. },
  449. // 合并表格
  450. mergeTd () {
  451. for(let i = 0; i < this.rowspan.length -1; i++) {
  452. if (this.rowspan[i].split('_')[0] !== this.rowspan[i+1].split('_')[0]) {
  453. this.$message({
  454. type: 'error',
  455. message: '合并失败,不能横向进行合并!'
  456. })
  457. return
  458. } else if (this.rowspan[i].split('_')[0] !== 'cartonNum' && this.rowspan[i].split('_')[0] !== 'netWeight' && this.rowspan[i].split('_')[0] !== 'grossWeight') {
  459. this.$message({
  460. type: 'error',
  461. message: '只能对箱数、净重、毛重进行合并!'
  462. })
  463. return
  464. }
  465. }
  466. this.rowspan.sort((a, b) => {return a.split('_')[2] - b.split('_')[2]})
  467. let minRow = this.rowspan[0]
  468. let maxRow = this.rowspan[this.rowspan.length-1]
  469. if (this.rowspan.length < 2) {
  470. this.$message({
  471. type: 'error',
  472. message: '必须含两个选择单元格!'
  473. })
  474. } else if ((maxRow.split('_')[2] - minRow.split('_')[2] + 1) !== this.rowspan.length) {
  475. this.$message({
  476. type: 'error',
  477. message: '选择单元格必须是连续的!'
  478. })
  479. } else {
  480. this.form.commissionSheetDetail[minRow.split('_')[1]].rowspan[minRow.split('_')[0]] = this.rowspan.length
  481. for(let j = Number(minRow.split('_')[1]); j <= Number(maxRow.split('_')[2]); j++) {
  482. this.form.commissionSheetDetail[j].splitData[minRow.split('_')[0]] = `${minRow.split('_')[0]}_${minRow.split('_')[1]}_${maxRow.split('_')[1]}`
  483. this.form.commissionSheetDetail[Number(minRow.split('_')[1])].isSelect[minRow.split('_')[0]] = false
  484. if (j !== Number(minRow.split('_')[1])) {
  485. this.form.commissionSheetDetail[j].show[minRow.split('_')[0]] = false
  486. this.form.commissionSheetDetail[j].isSelect[minRow.split('_')[0]] = false
  487. this.form.commissionSheetDetail[j][minRow.split('_')[0]] = -1
  488. }
  489. }
  490. this.rowspan = []
  491. }
  492. },
  493. // 拆分表格
  494. splitTd () {
  495. if (this.rowspan.length > 0 && this.rowspan.length === 1 && (this.rowspan[0].split('_')[1] !== this.rowspan[0].split('_')[2])) {
  496. let rowMin = Number(this.rowspan[0].split('_')[1])
  497. let rowMax = Number(this.rowspan[0].split('_')[2])
  498. let name = this.rowspan[0].split('_')[0]
  499. this.form.commissionSheetDetail[rowMin].rowspan[name] = 1
  500. for (let i = rowMin; i <= rowMax; i++) {
  501. this.form.commissionSheetDetail[i].isSelect[name] = false
  502. this.form.commissionSheetDetail[i].splitData[name] = `${name}_${i}_${i}`
  503. if (i !== rowMin) {
  504. this.form.commissionSheetDetail[i].rowspan[name] = 1
  505. this.form.commissionSheetDetail[i].show[name] = true
  506. this.form.commissionSheetDetail[i][name] = 0
  507. }
  508. }
  509. this.rowspan = []
  510. } else {
  511. this.$message({
  512. type: 'error',
  513. message: '请选择一个合并过的单元格!'
  514. })
  515. }
  516. },
  517. // 表格增加一行
  518. addTable () {
  519. let _arr = {
  520. detno: '',
  521. commodityNameSimplify: '',
  522. cmpCode: '',
  523. amount: '',
  524. cartonNum: '',
  525. netWeight: '',
  526. grossWeight: '',
  527. currency: '',
  528. unitPrice: '',
  529. totalPrice: '',
  530. brand: '',
  531. producingAreaSimplify: '',
  532. batchNum: '',
  533. remarkSimplify: ''
  534. }
  535. for (let j = 0; j < this.tableData.attr.length; j++) {
  536. let _n = {}
  537. for (let k = 0; k < this.tableData.thead.length; k++) {
  538. if (this.tableData.attr[j].id === 'splitData') {
  539. _n[this.tableData.thead[k].id] = `${this.tableData.thead[k].id}_${this.form.commissionSheetDetail.length}_${this.form.commissionSheetDetail.length}`
  540. } else {
  541. _n[this.tableData.thead[k].id] = this.tableData.attr[j].default
  542. }
  543. }
  544. _arr[this.tableData.attr[j].id] = _n
  545. }
  546. this.form.commissionSheetDetail.push(_arr)
  547. },
  548. // 单元格单击
  549. cellClick (key, name) {
  550. this.form.commissionSheetDetail[key].isSelect[name] = !this.form.commissionSheetDetail[key].isSelect[name]
  551. if (this.rowspan.length === 0) {
  552. this.rowspan.push(this.form.commissionSheetDetail[key].splitData[name])
  553. } else {
  554. for(let index = 0; index < this.rowspan.length; index++) {
  555. if (this.rowspan[index].split('_')[1] === key.toString() && this.rowspan[index].split('_')[0] === name) {
  556. if (this.form.commissionSheetDetail[key].isSelect[name] === false) {
  557. this.rowspan.splice(index, 1)
  558. break
  559. }
  560. } else {
  561. if (this.form.commissionSheetDetail[key].isSelect[name] === true) {
  562. this.rowspan.push(this.form.commissionSheetDetail[key].splitData[name])
  563. break
  564. }
  565. }
  566. }
  567. }
  568. },
  569. // 表格双击
  570. dblclick (name, key) {
  571. this.form.commissionSheetDetail[key].dblclick[name] = !this.form.commissionSheetDetail[key].dblclick[name]
  572. this.form.commissionSheetDetail[key].isSelect[name] = false
  573. this.$nextTick (()=> {
  574. this.$refs[name + key + ''][0].focus()
  575. })
  576. },
  577. // 上传成功后的回调
  578. uploadSuccess (res, file, fileList) {
  579. console.log(file, fileList)
  580. if (res.success) {
  581. this.$message({
  582. message: '文件上传成功',
  583. type: 'success'
  584. })
  585. } else {
  586. this.$message.error(res.message)
  587. }
  588. },
  589. // 上传错误
  590. uploadError (res, file, fileList) {
  591. console.log(file, fileList)
  592. this.$message.error('上传失败,请重新上传文件!')
  593. },
  594. // 选择文件,对文件内容打包处理
  595. selectFile (file) {
  596. this.form.deliveryFileUrl = file.name
  597. this.fileList.push(file)
  598. },
  599. // 验证手机号
  600. checkTel (rule, value, callback) {
  601. if (!value) {
  602. return callback(new Error('联系方式不能为空'))
  603. } else {
  604. let reg = /^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\D])|(18[0,5-9]))\d{8}$/
  605. if (!(reg.test(value))) {
  606. callback(new Error('请输入正确的手机号'))
  607. } else {
  608. callback()
  609. }
  610. }
  611. },
  612. // 验证商品名称
  613. vaildCommodityName (type) {
  614. this.form.commissionSheetDetail[type].dblclick.commodityName = false
  615. this.form.commissionSheetDetail[type].isSelect.commodityName = false
  616. if (this.form.commissionSheetDetail[type].commodityName == '') {
  617. this.form.commissionSheetDetail[type].errMsg.commodityName = true
  618. this.$message({
  619. message: '请填写' + (type + 1) + '行商品名称内容,不能为空!',
  620. type: 'warning'
  621. })
  622. } else {
  623. this.form.commissionSheetDetail[type].errMsg.commodityName = false
  624. }
  625. },
  626. // 验证规格型号
  627. vaildCmpCode (type) {
  628. this.form.commissionSheetDetail[type].dblclick.cmpCode = false
  629. this.form.commissionSheetDetail[type].isSelect.cmpCode = false
  630. let reg = /[\u4E00-\u9FA5\uf900-\ufa2d]/
  631. if (this.form.commissionSheetDetail[type].cmpCode == '') {
  632. this.form.commissionSheetDetail[type].errMsg.cmpCode = true
  633. this.$message({
  634. message: '请填写序号' + (type + 1) + '行商品规格型号内容,不能为空!',
  635. type: 'warning'
  636. })
  637. } else if (reg.test(this.form.commissionSheetDetail[type].cmpCode)) {
  638. this.form.commissionSheetDetail[type].errMsg.cmpCode = true
  639. this.$message({
  640. message: '请注意序号' + (type + 1) + '行商品规格型号内容,不能含中文字符!',
  641. type: 'warning'
  642. })
  643. } else {
  644. this.form.commissionSheetDetail[type].errMsg.cmpCode = false
  645. }
  646. },
  647. // 验证数量
  648. vaildAmount (type) {
  649. this.form.commissionSheetDetail[type].dblclick.amount = false
  650. this.form.commissionSheetDetail[type].isSelect.amount = false
  651. let reg = /^[1-9]([0-9])*$/
  652. if (this.form.commissionSheetDetail[type].amount == '') {
  653. this.form.commissionSheetDetail[type].errMsg.amount = true
  654. this.$message({
  655. message: '请填写序号' + (type + 1) + '行商品数量内容,不能为空!',
  656. type: 'warning'
  657. })
  658. } else if (!reg.test(this.form.commissionSheetDetail[type].amount)) {
  659. this.form.commissionSheetDetail[type].errMsg.amount = true
  660. this.$message({
  661. message: '请填写序号' + (type + 1) + '行商品数量内容,必须是正整数!',
  662. type: 'warning'
  663. })
  664. } else {
  665. this.form.commissionSheetDetail[type].errMsg.amount = false
  666. }
  667. },
  668. // 验证箱数
  669. vaildCartonNum (type) {
  670. this.form.commissionSheetDetail[type].dblclick.cartonNum = false
  671. this.form.commissionSheetDetail[type].isSelect.cartonNum = false
  672. let reg = /(^[1-9]([0-9])*$)|(^(-1){1}$)/
  673. if (this.form.commissionSheetDetail[type].cartonNum == '') {
  674. this.form.commissionSheetDetail[type].errMsg.cartonNum = true
  675. this.$message({
  676. message: '请填写序号' + (type + 1) + '行箱数内容,不能为空!',
  677. type: 'warning'
  678. })
  679. } else if (!reg.test(this.form.commissionSheetDetail[type].cartonNum)) {
  680. this.form.commissionSheetDetail[type].errMsg.cartonNum = true
  681. this.$message({
  682. message: '请填写序号' + (type + 1) + '行箱数内容为正整数。为*号表示向下合并单元格!',
  683. type: 'warning'
  684. })
  685. } else {
  686. this.vaildNetWeight(type)
  687. this.vaildGrossWeight(type)
  688. this.form.commissionSheetDetail[type].errMsg.cartonNum = false
  689. }
  690. },
  691. // 验证净重
  692. vaildNetWeight (type) {
  693. this.form.commissionSheetDetail[type].dblclick.netWeight = false
  694. this.form.commissionSheetDetail[type].isSelect.netWeight = false
  695. let reg = /(^[0-9]+(\.[0-9]{1,2})?$)|(^(-1){1}$)/
  696. if (this.form.commissionSheetDetail[type].netWeight == '') {
  697. this.form.commissionSheetDetail[type].errMsg.netWeight = true
  698. this.$message({
  699. message: '请填写序号' + (type + 1) + '行净重内容,不能为空!',
  700. type: 'warning'
  701. })
  702. } else {
  703. if (this.form.commissionSheetDetail[type].netWeight == '*' && (this.form.commissionSheetDetail[type].cartonNum != '*' || this.form.commissionSheetDetail[type].grossWeight != '*')) {
  704. this.form.commissionSheetDetail[type].errMsg.netWeight = true
  705. this.$message({
  706. message: '请填写序号' + (type + 1) + '行净重内容有误,净重合并的情况必须毛重和箱数都要合并,请确认!',
  707. type: 'warning'
  708. })
  709. } else if (!reg.test(this.form.commissionSheetDetail[type].netWeight)) {
  710. this.form.commissionSheetDetail[type].errMsg.netWeight = true
  711. this.$message({
  712. message: '请填写序号' + (type + 1) + '行净重内容只保留两位有效数值!',
  713. type: 'warning'
  714. })
  715. } else {
  716. this.form.commissionSheetDetail[type].errMsg.netWeight = false
  717. }
  718. }
  719. },
  720. // 验证毛重
  721. vaildGrossWeight (type) {
  722. this.form.commissionSheetDetail[type].dblclick.grossWeight = false
  723. this.form.commissionSheetDetail[type].isSelect.grossWeight = false
  724. let reg = /(^[0-9]+(\.[0-9]{1,2})?$)|(^(-1){1}$)/
  725. if (this.form.commissionSheetDetail[type].grossWeight == '') {
  726. this.form.commissionSheetDetail[type].errMsg.grossWeight = true
  727. this.$message({
  728. message: '请填写序号' + (type + 1) + '行毛重内容,不能为空!',
  729. type: 'warning'
  730. })
  731. } else {
  732. if (this.form.commissionSheetDetail[type].cartonNum != '*' && this.form.commissionSheetDetail[type].grossWeight == '*') {
  733. this.form.commissionSheetDetail[type].errMsg.grossWeight = true
  734. this.$message({
  735. message: '请填写序号' + (type + 1) + '行毛重内容有误,毛重合并的情况箱数必须合并,请确认!',
  736. type: 'warning'
  737. })
  738. } else if (!reg.test(this.form.commissionSheetDetail[type].grossWeight)) {
  739. this.form.commissionSheetDetail[type].errMsg.grossWeight = true
  740. this.$message({
  741. message: '请填写序号' + (type + 1) + '行毛重内容只保留两位有效数值!',
  742. type: 'warning'
  743. })
  744. } else {
  745. this.vaildNetWeight(type)
  746. this.form.commissionSheetDetail[type].errMsg.grossWeight = false
  747. }
  748. }
  749. },
  750. // 验证币种
  751. vaildCurrency (type) {
  752. this.form.commissionSheetDetail[type].dblclick.currency = false
  753. this.form.commissionSheetDetail[type].isSelect.currency = false
  754. if (this.form.commissionSheetDetail[type].currency == '') {
  755. this.form.commissionSheetDetail[type].errMsg.currency = true
  756. this.$message({
  757. message: '请填写序号' + (type + 1) + '行币种内容,不能为空!',
  758. type: 'warning'
  759. })
  760. } else {
  761. this.form.commissionSheetDetail[type].errMsg.currency = false
  762. }
  763. },
  764. // 验证单价
  765. vaildUnitPrice (type) {
  766. this.form.commissionSheetDetail[type].dblclick.unitPrice = false
  767. this.form.commissionSheetDetail[type].isSelect.unitPrice = false
  768. let reg = /^\d*\.?\d{0,4}$/
  769. if (this.form.commissionSheetDetail[type].unitPrice == '') {
  770. this.form.commissionSheetDetail[type].errMsg.unitPrice = true
  771. this.$message({
  772. message: '请填写序号' + (type + 1) + '行单价内容,不能为空!',
  773. type: 'warning'
  774. })
  775. } else if (!reg.test(this.form.commissionSheetDetail[type].unitPrice)) {
  776. this.form.commissionSheetDetail[type].errMsg.unitPrice = true
  777. this.$message({
  778. message: '请填写序号' + (type + 1) + '行单价内容只保留四位有效数值!',
  779. type: 'warning'
  780. })
  781. } else {
  782. this.form.commissionSheetDetail[type].errMsg.unitPrice = false
  783. }
  784. },
  785. // 验证总价
  786. vaildTotalPrice (type) {
  787. this.form.commissionSheetDetail[type].dblclick.totalPrice = false
  788. this.form.commissionSheetDetail[type].isSelect.totalPrice = false
  789. if (this.form.commissionSheetDetail[type].amount && this.form.commissionSheetDetail[type].unitPrice) {
  790. this.form.commissionSheetDetail[type].totalPrice = this.form.commissionSheetDetail[type].amount * this.form.commissionSheetDetail[type].unitPrice
  791. let reg = /^\d*\.?\d{0,4}$/
  792. if (this.form.commissionSheetDetail[type].totalPrice == '') {
  793. this.form.commissionSheetDetail[type].errMsg.totalPrice = true
  794. this.$message({
  795. message: '请填写序号' + (type + 1) + '行总价内容,不能为空!',
  796. type: 'warning'
  797. })
  798. } else if (!reg.test(this.form.commissionSheetDetail[type].totalPrice)) {
  799. this.form.commissionSheetDetail[type].errMsg.totalPrice = true
  800. this.$message({
  801. message: '请填写序号' + (type + 1) + '行总价内容只保留四位有效数值!',
  802. type: 'warning'
  803. })
  804. } else {
  805. this.form.commissionSheetDetail[type].errMsg.totalPrice = false
  806. }
  807. }
  808. },
  809. // 验证品牌
  810. vaildBrand (type) {
  811. this.form.commissionSheetDetail[type].dblclick.brand = false
  812. this.form.commissionSheetDetail[type].isSelect.brand = false
  813. if (this.form.commissionSheetDetail[type].brand == '') {
  814. this.form.commissionSheetDetail[type].errMsg.brand = true
  815. this.$message({
  816. message: '请填写序号' + (type + 1) + '行品牌内容,不能为空!',
  817. type: 'warning'
  818. })
  819. } else {
  820. this.form.commissionSheetDetail[type].errMsg.brand = false
  821. }
  822. },
  823. // 验证产地
  824. vaildProducingArea (type) {
  825. this.form.commissionSheetDetail[type].dblclick.producingArea = false
  826. this.form.commissionSheetDetail[type].isSelect.producingArea = false
  827. if (this.form.commissionSheetDetail[type].producingArea == '') {
  828. this.form.commissionSheetDetail[type].errMsg.producingArea = true
  829. this.$message({
  830. message: '请填写序号' + (type + 1) + '行产地内容,不能为空!',
  831. type: 'warning'
  832. })
  833. } else {
  834. this.form.commissionSheetDetail[type].errMsg.producingArea = false
  835. }
  836. },
  837. // 验证批次
  838. vaildBatchNum (type) {
  839. this.form.commissionSheetDetail[type].dblclick.batchNum = false
  840. this.form.commissionSheetDetail[type].isSelect.batchNum = false
  841. if (this.form.commissionSheetDetail[type].batchNum == '') {
  842. this.form.commissionSheetDetail[type].errMsg.batchNum = true
  843. this.$message({
  844. message: '请填写序号' + (type + 1) + '行批次内容,不能为空!',
  845. type: 'warning'
  846. })
  847. } else {
  848. this.form.commissionSheetDetail[type].errMsg.batchNum = false
  849. }
  850. },
  851. // 验证备注信息
  852. vaildRemark (type) {
  853. this.form.commissionSheetDetail[type].dblclick.remark = false
  854. this.form.commissionSheetDetail[type].isSelect.remark = false
  855. },
  856. // 取消清空内容信息
  857. submitCancel (type) {
  858. this.$refs[type].clearValidate()
  859. this.clearSheet()
  860. },
  861. // 保存客户填写表单信息
  862. submitSave (type) {
  863. this.$refs[type].validate((valid) => {
  864. if (!valid) {
  865. this.$message({
  866. message: '请正确填写上面的信息,确认无误!',
  867. type: 'warning'
  868. })
  869. return false
  870. } else {
  871. let list = this.form.commissionSheetDetail
  872. for (let key of list.keys()) {
  873. this.vaildGrossWeight(key)
  874. this.vaildNetWeight(key)
  875. this.vaildCartonNum(key)
  876. this.vaildAmount(key)
  877. this.vaildBatchNum(key)
  878. this.vaildBrand(key)
  879. this.vaildCmpCode(key)
  880. this.vaildCommodityName(key)
  881. this.vaildCurrency(key)
  882. this.vaildProducingArea(key)
  883. this.vaildUnitPrice(key)
  884. }
  885. for(let i of list.values()) {
  886. if (i.errMsg.commodityName == true ||
  887. i.errMsg.amount == true ||
  888. i.errMsg.batchNum == true ||
  889. i.errMsg.brand == true ||
  890. i.errMsg.cartonNum == true ||
  891. i.errMsg.cmpCode == true ||
  892. i.errMsg.commodityName == true ||
  893. i.errMsg.currency == true ||
  894. i.errMsg.grossWeight == true ||
  895. i.errMsg.netWeight == true ||
  896. i.errMsg.producingArea == true ||
  897. i.errMsg.unitPrice == true ||
  898. i.errMsg.remark == true) {
  899. this.$message({
  900. message: '请正确填写上面的信息,确认无误!',
  901. type: 'warning'
  902. })
  903. return false
  904. }
  905. }
  906. for(let i of list.values()) {
  907. i.grossWeight == '*' ? i.grossWeight = null : i.grossWeight = Number(i.grossWeight)
  908. i.netWeight == '*' ? i.netWeight = null : i.netWeight = Number(i.netWeight)
  909. i.cartonNum == '*' ? i.cartonNum = null : i.cartonNum = Number(i.cartonNum)
  910. i.amount == '*' ? i.amount = null : i.amount = Number(i.amount)
  911. i.unitPrice = Number(i.unitPrice)
  912. i.totalPrice = Number(i.totalPrice)
  913. }
  914. this.form.commissionSheetDetail = list
  915. let params = new FormData()
  916. params.append('file' , this.fileList)
  917. params.append('params' , JSON.stringify(this.form))
  918. let config = {
  919. headers: {'Content-Type': 'multipart/form-data'}
  920. }
  921. this.$http.post('/CommissionSheet/save', params, config)
  922. .then(response => {
  923. if (response.data.success) {
  924. this.$message({
  925. message: '报关申请提交成功',
  926. type: 'success'
  927. })
  928. this.$router.push('/clientPage/' + response.data.content.id)
  929. } else {
  930. this.$message({
  931. message: response.data.message,
  932. type: 'warning'
  933. })
  934. this.$router.push('/clientPage/entrustApply/' + response.data.content.id)
  935. }
  936. }).catch(() => {
  937. this.$message.error( '请检查网络,提交失败!')
  938. })
  939. }
  940. })
  941. }
  942. }
  943. }
  944. </script>
  945. <style lang="scss" type="text/scss" scoped>
  946. .entrust-apply{
  947. padding:0 15px;
  948. margin-bottom:100px;
  949. h4{
  950. color:#0d5ffe;
  951. font-size: 14px;
  952. margin:20px auto;
  953. }
  954. .el-form-item {
  955. position:relative;
  956. margin: 0;
  957. .el-select{
  958. width:100%;
  959. }
  960. .input-title{
  961. position:absolute;
  962. top:0;
  963. right:-20px;
  964. &:hover{
  965. cursor:pointer;
  966. span{
  967. display: inline-block;
  968. width: 400px;
  969. line-height: 40px;
  970. z-index: 20000;
  971. position: absolute;
  972. left:25px;
  973. }
  974. }
  975. span{
  976. display:none;
  977. }
  978. }
  979. }
  980. .el-form-item__label{
  981. color:#333;
  982. }
  983. hr{
  984. border:2px dashed #eaeaea;
  985. margin: 25px auto;
  986. }
  987. .download{
  988. font-size: 16px;
  989. font-weight: bold;
  990. text-align: center;
  991. }
  992. .table-info{
  993. padding-top:30px;
  994. table{
  995. width:100%;
  996. table-layout: fixed;
  997. margin-bottom:20px;
  998. border-collapse: unset;
  999. border-spacing: 0;
  1000. th{
  1001. border: 1px solid #eee;
  1002. line-height: 46px;
  1003. background: #deeffe;
  1004. }
  1005. tr{
  1006. &.errmsg {
  1007. color: #F56C6C;
  1008. }
  1009. &:hover{
  1010. cursor:pointer;
  1011. }
  1012. }
  1013. td{
  1014. &.err{
  1015. border:1px solid red;
  1016. }
  1017. &.is_select{
  1018. background: #f0f7fe;
  1019. color:#0d5ffe;
  1020. }
  1021. border: 1px solid #eee;
  1022. text-align: center;
  1023. word-break: break-all;
  1024. word-wrap: break-word;
  1025. vertical-align: middle;
  1026. height:44px;
  1027. position:relative;
  1028. span{
  1029. line-height: 18px;
  1030. }
  1031. &:first-child:hover{
  1032. cursor:pointer;
  1033. span{
  1034. display:none;
  1035. }
  1036. .text-delete{
  1037. display:block;
  1038. }
  1039. }
  1040. &.show:hover{
  1041. cursor:default;
  1042. span{
  1043. display:block;
  1044. }
  1045. }
  1046. .text-delete{
  1047. display:none;
  1048. position:absolute;
  1049. top:0;
  1050. left:0;
  1051. width:40px;
  1052. height:40px;
  1053. line-height: 40px;
  1054. text-align: center;
  1055. i{
  1056. font-size: 18px;
  1057. font-weight: bold;
  1058. }
  1059. }
  1060. .err-info{
  1061. position:absolute;
  1062. display:inline-block;
  1063. width:15px;
  1064. height:15px;
  1065. top:0;
  1066. right:0;
  1067. &:hover{
  1068. cursor:pointer;
  1069. p{
  1070. display:block;
  1071. }
  1072. }
  1073. i{
  1074. color:red;
  1075. font-size: 16px;
  1076. vertical-align:top;
  1077. }
  1078. p{
  1079. position: absolute;
  1080. display: none;
  1081. width: 160px;
  1082. height: 50px;
  1083. line-height: 20px;
  1084. background: #fff;
  1085. bottom: -50%;
  1086. right: 20px;
  1087. z-index: 20000;
  1088. box-shadow: 0 0 5px rgba(0,0,0,.7);
  1089. font-size: 12px;
  1090. text-align: left;
  1091. color:#333;
  1092. padding-left:3px;
  1093. overflow-y: auto;
  1094. }
  1095. }
  1096. input{
  1097. width:100%;
  1098. font-size: 16px;
  1099. line-height: 40px;
  1100. border:none;
  1101. margin:0;
  1102. padding-left:5px;
  1103. }
  1104. }
  1105. }
  1106. }
  1107. .form-btn{
  1108. margin-left:150px;
  1109. padding-top:55px;
  1110. }
  1111. }
  1112. </style>