chooseImportModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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 }}</div>
  35. <div v-else-if="item.productBrandName">{{ item.productBrandName }}<span v-if="item.productTypeShowName">/</span>{{ item.productTypeShowName }}</div>
  36. <div v-else>{{ item.productTypeShowName }}</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 }}</div>
  65. <div v-else-if="item.productBrandName">{{ item.productBrandName }}<span v-if="item.productTypeShowName">/</span>{{ item.productTypeShowName }}</div>
  66. <div v-else>{{ item.productTypeShowName }}</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. style="padding: 0 40px;">确认导入</a-button>
  90. <a-button
  91. id="chooseImport-cancel"
  92. size="large"
  93. class="button-cancel"
  94. @click="isShow=false"
  95. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  96. <a-button
  97. type="primary"
  98. id="chooseImport-error"
  99. size="large"
  100. class="button-error"
  101. @click="handleError"
  102. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  103. </div>
  104. </div>
  105. </a-modal>
  106. </template>
  107. <script>
  108. import { hdExportExcel } from '@/libs/exportExcel'
  109. import { expenseFailExcel } from '@/api/expenseManagement'
  110. export default {
  111. name: 'ChooseImportModal',
  112. props: {
  113. openModal: { // 弹框显示状态
  114. type: Boolean,
  115. default: false
  116. },
  117. paramsData: {
  118. type: Object,
  119. default: () => {
  120. return {}
  121. }
  122. }
  123. },
  124. data () {
  125. return {
  126. isShow: this.openModal, // 是否打开弹框
  127. // 正确列表
  128. nowColumns: [
  129. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  130. { title: '记账类型', dataIndex: 'importAccountType', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '记账名称', dataIndex: 'importAccountName', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '原记账名称', dataIndex: 'importAccountNameOrig', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '所属区域', dataIndex: 'subareaArea.subareaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '所属分区', dataIndex: 'subareaArea.subareaAreaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  135. { title: '所属省份', dataIndex: 'provinceName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  136. { title: '所属城市', dataIndex: 'cityName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '备注', dataIndex: 'remarks', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '费用承担方', scopedSlots: { customRender: 'fycdf' }, align: 'center', width: '10%' },
  139. { title: '产品信息', scopedSlots: { customRender: 'cpxx' }, align: 'center', width: '8%' }
  140. ],
  141. loadData: [],
  142. // 错误数据列表
  143. nowUnColumns: [
  144. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  145. { title: '记账类型', dataIndex: 'importAccountType', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '记账名称', dataIndex: 'importAccountName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '原记账名称', dataIndex: 'importAccountNameOrig', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '所属区域', dataIndex: 'subareaArea.subareaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '所属分区', dataIndex: 'subareaArea.subareaAreaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '所属省份', dataIndex: 'provinceName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '所属城市', dataIndex: 'cityName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  152. { title: '备注', dataIndex: 'remarks', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '费用承担方', scopedSlots: { customRender: 'fycdf' }, align: 'center', width: '10%' },
  154. { title: '产品信息', scopedSlots: { customRender: 'cpxx' }, align: 'center', width: '10%' },
  155. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '8%', align: 'center' }
  156. ],
  157. unLoadData: [],
  158. loading: false
  159. }
  160. },
  161. methods: {
  162. // 格式化产品数据
  163. formatProduct (list) {
  164. const ret = []
  165. list.map(item => {
  166. ret.push({
  167. productCode: item.productCode,
  168. expense: item.expense,
  169. productBrandName: item.productBrandName,
  170. productTypeShowName: (item.productTypeName3 ? (item.productTypeName2 + '>' + item.productTypeName3) : (item.productTypeName1 || item.productTypeName2 || ''))
  171. })
  172. })
  173. return ret
  174. },
  175. // 格式化承担人员数据
  176. formatSplit (list) {
  177. const ret = []
  178. list.map(item => {
  179. // 有承担人员
  180. if (item.childDetailSplitList && item.childDetailSplitList.length) {
  181. item.childDetailSplitList.map(k => {
  182. ret.push({
  183. splitObjName: item.importSplitObjName,
  184. splitObjType: item.importSplitObjType,
  185. splitAmount: k.splitAmount,
  186. childDetailSplit: {
  187. splitObjName: k.importSplitObjName
  188. }
  189. })
  190. })
  191. } else {
  192. // 没有承担人员
  193. ret.push({
  194. splitObjName: item.importSplitObjName,
  195. splitObjType: item.importSplitObjType,
  196. splitAmount: item.splitAmount
  197. })
  198. }
  199. })
  200. return ret
  201. },
  202. // 获取数据
  203. getData () {
  204. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  205. this.loadData = paramsData.rightList || []
  206. this.unLoadData = paramsData.errorList || []
  207. this.loadData.map((item, index) => {
  208. item.no = index + 1
  209. item.detailProductsList = this.formatProduct(item.detailProductsList)
  210. item.detailSplitList = this.formatSplit(item.detailSplitList)
  211. item.expenseAccountNo = paramsData.expenseAccountNo
  212. item.expenseAccountSn = paramsData.expenseAccountSn
  213. })
  214. this.unLoadData.map((item, index) => {
  215. item.no = index + 1
  216. item.detailProductsList = this.formatProduct(item.detailProductsList)
  217. item.detailSplitList = this.formatSplit(item.detailSplitList)
  218. item.expenseAccountNo = paramsData.expenseAccountNo
  219. item.expenseAccountSn = paramsData.expenseAccountSn
  220. })
  221. },
  222. // 确认导入
  223. handleSubmit () {
  224. if (this.paramsData.rightList.length == 0) {
  225. this.$message.warning('没有可导入的费用明细!')
  226. } else {
  227. const data = this.paramsData.rightList
  228. data.map(item => {
  229. item.expenseAccountNo = this.paramsData.expenseAccountNo
  230. item.expenseAccountSn = this.paramsData.expenseAccountSn
  231. })
  232. this.$emit('ok', data)
  233. this.isShow = false
  234. }
  235. },
  236. // 导出错误项
  237. handleError () {
  238. const _this = this
  239. if (_this.paramsData.errorList.length < 1) {
  240. _this.$message.info('暂无错误项!')
  241. return
  242. }
  243. _this.spinning = true
  244. hdExportExcel(expenseFailExcel, _this.paramsData.errorList, '费用明细导出错误项', function () {
  245. _this.spinning = false
  246. })
  247. }
  248. },
  249. watch: {
  250. // 父页面传过来的弹框状态
  251. openModal (newValue, oldValue) {
  252. this.isShow = newValue
  253. },
  254. // 重定义的弹框状态
  255. isShow (newValue, oldValue) {
  256. if (!newValue) {
  257. this.$emit('close')
  258. this.loadData = []
  259. this.unLoadData = []
  260. } else {
  261. this.getData()
  262. }
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="less" scoped>
  268. .chooseImport-modal{
  269. .chooseImport-con{
  270. .red{
  271. color: #f30;
  272. }
  273. .btn-con{
  274. text-align: center;
  275. margin: 30px 0 20px;
  276. .button-cancel,.button-error{
  277. font-size: 12px;
  278. }
  279. }
  280. }
  281. }
  282. </style>