chooseImportModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImport-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="确认导入"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="80%">
  11. <div class="chooseImport-con">
  12. <!-- 可导入数据 -->
  13. <p class="">可导入数据{{ loadData.length }}条</p>
  14. <a-table
  15. class="sTable"
  16. ref="table"
  17. size="small"
  18. :rowKey="(record) => record.id"
  19. :columns="nowColumns"
  20. :dataSource="loadData"
  21. :loading="loading"
  22. :scroll="{ y: 200 }"
  23. :pagination="false"
  24. bordered>
  25. </a-table>
  26. <a-divider />
  27. <!-- 不可导入数据 -->
  28. <p class="red">不可导入数据{{ unLoadData.length }}条</p>
  29. <a-table
  30. class="unTable"
  31. ref="unTable"
  32. size="small"
  33. :rowKey="(record) => record.id"
  34. :columns="nowUnColumns"
  35. :dataSource="unLoadData"
  36. :loading="loading"
  37. :scroll="{ y: 200 }"
  38. :pagination="false"
  39. bordered>
  40. </a-table>
  41. <!-- 按钮 -->
  42. <div class="btn-con">
  43. <a-button
  44. type="primary"
  45. id="chooseImport-submit"
  46. size="large"
  47. :class="loadData.length==0?'button-grey':'button-primary'"
  48. @click="handleSubmit"
  49. :loading="bloading"
  50. style="padding: 0 40px;">确认导入</a-button>
  51. <a-button
  52. id="chooseImport-cancel"
  53. size="large"
  54. class="button-cancel"
  55. :loading="bloading"
  56. @click="isShow=false"
  57. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  58. <a-button
  59. type="primary"
  60. id="chooseImport-error"
  61. size="large"
  62. class="button-error"
  63. :loading="bloading"
  64. @click="handleError"
  65. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  66. </div>
  67. </div>
  68. </a-modal>
  69. </template>
  70. <script>
  71. import { hdExportExcel } from '@/libs/exportExcel'
  72. import { sendBillInsertBatch, exportImportError } from '@/api/sendBill'
  73. export default {
  74. name: 'ChooseImportModal',
  75. props: {
  76. openModal: { // 弹框显示状态
  77. type: Boolean,
  78. default: false
  79. },
  80. paramsData: {
  81. type: Object,
  82. default: () => {
  83. return {}
  84. }
  85. }
  86. },
  87. data () {
  88. const renderContent = (value, row, index) => {
  89. const obj = {
  90. children: value || '--',
  91. attrs: { rowSpan: row.sendBillDetailList ? row.sendBillDetailList.length : 0 }
  92. }
  93. return obj
  94. }
  95. const renderContentError = (value, row, index) => {
  96. const obj = {
  97. children: <a-popover placement="topRight">
  98. <template slot="content">
  99. { row.importErrorMsgList.map(item => { return <div>{item}</div> }) }
  100. </template>
  101. <a-button type="link">
  102. 查看
  103. </a-button>
  104. </a-popover>,
  105. attrs: { rowSpan: row.sendBillDetailList ? row.sendBillDetailList.length : 0 }
  106. }
  107. return obj
  108. }
  109. return {
  110. bloading: false,
  111. isShow: this.openModal, // 是否打开弹框
  112. nowColumns: [
  113. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: renderContent },
  114. { title: '客户名称', dataIndex: 'customeName', width: '8%', align: 'left', customRender: renderContent },
  115. { title: '物流单号', dataIndex: 'transportNo', width: '8%', align: 'center', customRender: renderContent },
  116. { title: '物流电话', dataIndex: 'transportTele', width: '8%', align: 'center', customRender: renderContent },
  117. { title: '托运日期', dataIndex: 'sendDate', width: '8%', align: 'center', customRender: renderContent },
  118. { title: '收货人', dataIndex: 'customerCacateName', width: '6%', align: 'left', customRender: renderContent },
  119. { title: '收货电话', dataIndex: 'customerCacatePhone', width: '8%', align: 'center', customRender: renderContent },
  120. { title: '收货地址', dataIndex: 'customerAddressDetail', width: '8%', align: 'center', customRender: renderContent },
  121. { title: '目的地', dataIndex: 'customerAddress', width: '6%', align: 'center', customRender: renderContent },
  122. { title: '付款方式', dataIndex: 'payTypeDictValue', width: '6%', align: 'center', customRender: renderContent },
  123. { title: '交货方式', dataIndex: 'handoverTypeDictValue', width: '6%', align: 'center', customRender: renderContent },
  124. { title: '货物名称', dataIndex: 'goodsName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '件数', dataIndex: 'goodsQtyStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. { title: '体积(m3)', dataIndex: 'goodsVolumeStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. { title: '立方/元', dataIndex: 'cubeAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  128. { title: '重量(kg)', dataIndex: 'goodsWeightStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '每吨/元', dataIndex: 'tonAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '运费(元)', dataIndex: 'transportAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  131. { title: '送货费(元)', dataIndex: 'sendAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '其他(元)', dataIndex: 'otherAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  133. { title: '保价(万)', dataIndex: 'supportValueStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  134. ],
  135. loadData: [],
  136. nowUnColumns: [
  137. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: renderContent },
  138. { title: '客户名称', dataIndex: 'customeName', width: '8%', align: 'left', customRender: renderContent },
  139. { title: '物流单号', dataIndex: 'transportNo', width: '8%', align: 'center', customRender: renderContent },
  140. { title: '物流电话', dataIndex: 'transportTele', width: '8%', align: 'center', customRender: renderContent },
  141. { title: '托运日期', dataIndex: 'sendDate', width: '8%', align: 'center', customRender: renderContent },
  142. { title: '收货人', dataIndex: 'customerCacateName', width: '6%', align: 'left', customRender: renderContent },
  143. { title: '收货电话', dataIndex: 'customerCacatePhone', width: '8%', align: 'center', customRender: renderContent },
  144. { title: '收货地址', dataIndex: 'customerAddressDetail', width: '8%', align: 'center', customRender: renderContent },
  145. { title: '目的地', dataIndex: 'customerAddress', width: '6%', align: 'center', customRender: renderContent },
  146. { title: '付款方式', dataIndex: 'payTypeDictValue', width: '6%', align: 'center', customRender: renderContent },
  147. { title: '交货方式', dataIndex: 'handoverTypeDictValue', width: '6%', align: 'center', customRender: renderContent },
  148. { title: '货物名称', dataIndex: 'goodsName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '件数', dataIndex: 'goodsQtyStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '体积(m3)', dataIndex: 'goodsVolumeStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '立方/元', dataIndex: 'cubeAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  152. { title: '重量(kg)', dataIndex: 'goodsWeightStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  153. { title: '每吨/元', dataIndex: 'tonAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. { title: '运费(元)', dataIndex: 'transportAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  155. { title: '送货费(元)', dataIndex: 'sendAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  156. { title: '其他(元)', dataIndex: 'otherAmountStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  157. { title: '保价(万)', dataIndex: 'supportValueStr', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  158. { title: '错误说明', dataIndex: 'importErrorMsgList', width: '10%', align: 'center', customRender: renderContentError }
  159. ],
  160. unLoadData: [],
  161. loading: false
  162. }
  163. },
  164. methods: {
  165. formatData (data) {
  166. const ret = []
  167. data.map((item, index) => {
  168. item.no = index + 1
  169. item.id = new Date().getTime() + index
  170. const clist = item.sendBillDetailList
  171. clist.map((k, i) => {
  172. if (i > 0) {
  173. ret.push(k)
  174. } else {
  175. ret.push(Object.assign(item, k))
  176. }
  177. })
  178. })
  179. return ret
  180. },
  181. getData () {
  182. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  183. this.loadData = this.formatData(paramsData.rightList || [])
  184. this.unLoadData = this.formatData(paramsData.errorList || [])
  185. console.log(this.loadData)
  186. console.log(this.unLoadData)
  187. },
  188. // 确认导入
  189. handleSubmit () {
  190. if (this.paramsData.rightList.length == 0) {
  191. this.$message.warning('没有可导入的发货单!')
  192. } else {
  193. const data = this.paramsData.rightList
  194. this.bloading = true
  195. sendBillInsertBatch(data).then(res => {
  196. if (res.status == 200) {
  197. this.isShow = false
  198. this.$emit('ok')
  199. }
  200. this.bloading = false
  201. })
  202. }
  203. },
  204. // 错误项
  205. handleError () {
  206. const _this = this
  207. if (_this.paramsData.errorList.length < 1) {
  208. _this.$message.info('暂无错误项!')
  209. return
  210. }
  211. _this.bloading = true
  212. hdExportExcel(exportImportError, _this.paramsData.errorList, '发货单导出错误项', function () {
  213. _this.bloading = false
  214. })
  215. }
  216. },
  217. watch: {
  218. // 父页面传过来的弹框状态
  219. openModal (newValue, oldValue) {
  220. this.isShow = newValue
  221. },
  222. // 重定义的弹框状态
  223. isShow (newValue, oldValue) {
  224. if (!newValue) {
  225. this.$emit('close')
  226. this.loadData = []
  227. this.unLoadData = []
  228. } else {
  229. this.getData()
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="less" scoped>
  236. .chooseImport-modal{
  237. .chooseImport-con{
  238. .red{
  239. color: #f30;
  240. }
  241. .btn-con{
  242. text-align: center;
  243. margin: 30px 0 20px;
  244. .button-cancel,.button-error{
  245. font-size: 12px;
  246. }
  247. }
  248. }
  249. }
  250. </style>