chooseImportModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImport-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="确认导入"
  8. v-model="isShow"
  9. @cancle="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. 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. nowColumns: [
  128. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  129. { title: '记账类型', dataIndex: 'importAccountType', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '记账名称', dataIndex: 'importAccountName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '所属区域', dataIndex: 'subareaNames', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '所属省份', dataIndex: 'provinceName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  133. { title: '所属城市', dataIndex: 'cityName', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '备注', dataIndex: 'remarks', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  135. { title: '费用承担方', scopedSlots: { customRender: 'fycdf' }, align: 'center', width: '15%' },
  136. { title: '产品信息', scopedSlots: { customRender: 'cpxx' }, align: 'center', width: '15%' }
  137. ],
  138. loadData: [],
  139. nowUnColumns: [
  140. { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
  141. { title: '记账类型', dataIndex: 'importAccountType', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '记账名称', dataIndex: 'importAccountName', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '所属区域', dataIndex: 'subareaNames', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '所属省份', dataIndex: 'provinceName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  145. { title: '所属城市', dataIndex: 'cityName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '备注', dataIndex: 'remarks', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '费用承担方', scopedSlots: { customRender: 'fycdf' }, align: 'center', width: '15%' },
  148. { title: '产品信息', scopedSlots: { customRender: 'cpxx' }, align: 'center', width: '15%' },
  149. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  150. ],
  151. unLoadData: [],
  152. loading: false
  153. }
  154. },
  155. methods: {
  156. // 格式化数据
  157. formatProduct (list) {
  158. const ret = []
  159. list.map(item => {
  160. ret.push({
  161. productCode: item.productCode,
  162. expense: item.expense,
  163. productBrandName: item.productBrandName,
  164. productTypeShowName: (item.productTypeName3 ? (item.productTypeName2 + '>' + item.productTypeName3) : (item.productTypeName1 || item.productTypeName2 || ''))
  165. })
  166. })
  167. return ret
  168. },
  169. formatSplit (list) {
  170. const ret = []
  171. list.map(item => {
  172. // 有承担人员
  173. if (item.childDetailSplitList) {
  174. item.childDetailSplitList.map(k => {
  175. ret.push({
  176. splitObjName: item.importSplitObjName,
  177. splitObjType: item.importSplitObjType,
  178. splitAmount: k.splitAmount,
  179. childDetailSplit: {
  180. splitObjName: k.importSplitObjName
  181. }
  182. })
  183. })
  184. } else {
  185. ret.push({
  186. splitObjName: item.importSplitObjName,
  187. splitObjType: item.importSplitObjType,
  188. splitAmount: item.splitAmount
  189. })
  190. }
  191. })
  192. return ret
  193. },
  194. getData () {
  195. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  196. this.loadData = paramsData.rightList || []
  197. this.unLoadData = paramsData.errorList || []
  198. this.loadData.map((item, index) => {
  199. item.no = index + 1
  200. item.detailProductsList = this.formatProduct(item.detailProductsList)
  201. item.detailSplitList = this.formatSplit(item.detailSplitList)
  202. item.expenseAccountNo = paramsData.expenseAccountNo
  203. item.expenseAccountSn = paramsData.expenseAccountSn
  204. })
  205. this.unLoadData.map((item, index) => {
  206. item.no = index + 1
  207. item.detailProductsList = this.formatProduct(item.detailProductsList)
  208. item.detailSplitList = this.formatSplit(item.detailSplitList)
  209. item.expenseAccountNo = paramsData.expenseAccountNo
  210. item.expenseAccountSn = paramsData.expenseAccountSn
  211. })
  212. },
  213. // 确认导入
  214. handleSubmit () {
  215. if (this.paramsData.rightList.length == 0) {
  216. this.$message.warning('无可导入费用明细!')
  217. } else {
  218. const data = this.paramsData.rightList
  219. data.map(item => {
  220. item.expenseAccountNo = this.paramsData.expenseAccountNo
  221. item.expenseAccountSn = this.paramsData.expenseAccountSn
  222. })
  223. this.$emit('ok', data)
  224. this.isShow = false
  225. }
  226. },
  227. // 导出
  228. handleError () {
  229. const _this = this
  230. if (_this.paramsData.errorList.length < 1) {
  231. _this.$message.info('暂无可导出错误项~')
  232. return
  233. }
  234. _this.spinning = true
  235. hdExportExcel(expenseFailExcel, _this.paramsData.errorList, '费用明细导入错误项', function () {
  236. _this.spinning = false
  237. })
  238. }
  239. },
  240. watch: {
  241. // 父页面传过来的弹框状态
  242. openModal (newValue, oldValue) {
  243. this.isShow = newValue
  244. },
  245. // 重定义的弹框状态
  246. isShow (newValue, oldValue) {
  247. if (!newValue) {
  248. this.$emit('close')
  249. this.loadData = []
  250. this.unLoadData = []
  251. } else {
  252. this.getData()
  253. }
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="less" scoped>
  259. .chooseImport-modal{
  260. .chooseImport-con{
  261. .red{
  262. color: #f30;
  263. }
  264. .btn-con{
  265. text-align: center;
  266. margin: 30px 0 20px;
  267. .button-cancel,.button-error{
  268. font-size: 12px;
  269. }
  270. }
  271. }
  272. }
  273. </style>