chooseImportModal.vue 14 KB

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