index.vue 56 KB

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