inventoryTable.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <ele-pro-table show-summary :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  4. :columns="columns" max-height="500px" :toolkit="[]" :datasource="datasource"
  5. cache-key="systemRoleTable17-1111" class="time-form">
  6. <!-- 表头工具栏 -->
  7. <template v-slot:action="{ row,$index }">
  8. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  9. <template v-slot:reference>
  10. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  11. 删除
  12. </el-link>
  13. </template>
  14. </el-popconfirm>
  15. </template>
  16. <template v-slot:productName="{ row,$index }">
  17. <el-popover
  18. placement="right"
  19. width="80%"
  20. trigger="hover">
  21. <ele-pro-table ref="childrenTable"
  22. row-key="id"
  23. max-height="300px"
  24. :needPage="false" :columns="childrenColumns" :toolkit="[]"
  25. :datasource="row.productList"
  26. cache-key="systemRoleTable17-222" class="time-form">
  27. </ele-pro-table>
  28. <el-button type="text" slot="reference">{{ row.productName }}</el-button>
  29. </el-popover>
  30. </template>
  31. </ele-pro-table>
  32. <el-row v-if="dialogType=='view'" style="margin-top: 10px">
  33. <el-col :span="6" style="float: right;">
  34. <el-descriptions class="margin-top" direction="vertical" :column="3" size="small" border>
  35. <el-descriptions-item label="未付款总金额">{{ dataForm.amountNotPaidPrice }}</el-descriptions-item>
  36. <el-descriptions-item label="未开票总金额">
  37. <template>{{ dataForm.amountNotInvoicedPrice }}</template>
  38. </el-descriptions-item>
  39. </el-descriptions>
  40. </el-col>
  41. </el-row>
  42. </el-form>
  43. </template>
  44. <script>
  45. export default {
  46. components: {},
  47. props: ['datasource', 'dialogType','dataForm'],
  48. computed: {
  49. columns() {
  50. let basicFields = [
  51. {
  52. width: 60,
  53. label: '序号',
  54. type: 'index',
  55. columnKey: 'index',
  56. align: 'center',
  57. },
  58. {
  59. minWidth: 130,
  60. prop: 'contractNo',
  61. label: '合同编号',
  62. align: 'center',
  63. slot: 'contractNo',
  64. },
  65. {
  66. minWidth: 120,
  67. prop: 'orderNo',
  68. label: '采购订单编码',
  69. slot: 'orderNo',
  70. align: 'center',
  71. showOverflowTooltip: true
  72. },
  73. {
  74. minWidth: 140,
  75. prop: 'productName',
  76. label: '产品名称',
  77. slot: 'productName',
  78. align: 'center',
  79. showOverflowTooltip: true
  80. },
  81. {
  82. minWidth: 100,
  83. prop: 'specification',
  84. label: '规格',
  85. align: 'center',
  86. slot: 'specification',
  87. showOverflowTooltip: true
  88. },
  89. {
  90. minWidth: 100,
  91. prop: 'modelType',
  92. label: '型号',
  93. align: 'center',
  94. slot: 'modelType',
  95. showOverflowTooltip: true
  96. },
  97. {
  98. minWidth: 130,
  99. prop: 'contractTotalCount',
  100. label: '合同总数量',
  101. align: 'center',
  102. slot: 'contractTotalCount'
  103. },
  104. {
  105. minWidth: 100,
  106. prop: 'singlePrice',
  107. label: '单价',
  108. align: 'center',
  109. slot: 'singlePrice'
  110. },
  111. {
  112. minWidth: 100,
  113. prop: 'discountSinglePrice',
  114. label: '折后单价',
  115. align: 'center',
  116. slot: 'discountSinglePrice'
  117. },
  118. {
  119. minWidth: 130,
  120. prop: 'contractTotalPrice',
  121. label: '合同总金额',
  122. align: 'center',
  123. slot: 'contractTotalPrice'
  124. },
  125. {
  126. minWidth: 140,
  127. prop: 'receiveGoodsDate',
  128. label: '收货日期',
  129. align: 'center',
  130. slot: 'receiveGoodsDate',
  131. showOverflowTooltip: true
  132. },
  133. {
  134. minWidth: 120,
  135. prop: 'totalCount',
  136. label: '已收货数量',
  137. align: 'center',
  138. slot: 'totalCount'
  139. },
  140. {
  141. minWidth: 130,
  142. prop: 'totalPrice',
  143. label: '已收货金额',
  144. align: 'center',
  145. slot: 'totalPrice'
  146. },
  147. {
  148. minWidth: 130,
  149. prop: 'discountTotalPrice',
  150. label: '折后已收货金额',
  151. align: 'center',
  152. slot: 'discountTotalPrice'
  153. },
  154. ]
  155. let permissionType = {
  156. // 'add': [
  157. // {
  158. // columnKey: 'action',
  159. // label: '操作',
  160. // width: 120,
  161. // align: 'center',
  162. // resizable: false,
  163. // slot: 'action',
  164. // fixed: 'right',
  165. // showOverflowTooltip: true
  166. // }
  167. // ],
  168. // 'update': [
  169. // {
  170. // columnKey: 'action',
  171. // label: '操作',
  172. // width: 120,
  173. // align: 'center',
  174. // resizable: false,
  175. // slot: 'action',
  176. // fixed: 'right',
  177. // showOverflowTooltip: true
  178. // }
  179. // ],
  180. 'view': [
  181. {
  182. minWidth: 140,
  183. prop: 'paidDate',
  184. label: '付款日期',
  185. align: 'center',
  186. slot: 'paidDate',
  187. showOverflowTooltip: true
  188. },
  189. {
  190. minWidth: 130,
  191. prop: 'paidPrice',
  192. label: '已付款金额',
  193. align: 'center',
  194. slot: 'paidPrice'
  195. },
  196. {
  197. minWidth: 130,
  198. prop: 'notPaidPrice',
  199. label: '应付款金额',
  200. align: 'center',
  201. slot: 'notPaidPrice'
  202. },
  203. {
  204. minWidth: 130,
  205. prop: 'invoicedPrice',
  206. label: '已开票金额',
  207. align: 'center',
  208. slot: 'invoicedPrice'
  209. },
  210. {
  211. minWidth: 130,
  212. prop: 'notInvoicedPrice',
  213. label: '未开票金额',
  214. align: 'center',
  215. slot: 'notInvoicedPrice'
  216. },
  217. ]
  218. }
  219. permissionType[this.dialogType] && basicFields.push(...permissionType[this.dialogType])
  220. console.log(basicFields);
  221. return basicFields
  222. },
  223. },
  224. data() {
  225. return {
  226. rules: {},
  227. form: {},
  228. childrenColumns: [
  229. {
  230. minWidth: 120,
  231. prop: 'orderNo',
  232. label: '单据编码',
  233. align: 'center',
  234. slot: 'orderNo'
  235. },
  236. {
  237. minWidth: 120,
  238. prop: 'orderType',
  239. label: '单据类型',
  240. slot: 'orderType',
  241. align: 'center',
  242. formatter: (_row, _column, cellValue) => {
  243. return _row.orderType === 1 ? '销售发货' : _row.orderType === 2 ? '销售退货' : ""
  244. }
  245. },
  246. {
  247. minWidth: 140,
  248. prop: 'productName',
  249. label: '产品名称',
  250. align: 'center',
  251. slot: 'productName',
  252. },
  253. {
  254. minWidth: 100,
  255. prop: 'productCode',
  256. label: '编码',
  257. align: 'center',
  258. slot: 'productCode'
  259. },
  260. {
  261. minWidth: 100,
  262. prop: 'productBrand',
  263. label: '牌号',
  264. align: 'center',
  265. slot: 'productBrand'
  266. },
  267. {
  268. minWidth: 100,
  269. prop: 'modelType',
  270. label: '型号',
  271. align: 'center',
  272. slot: 'modelType'
  273. },
  274. {
  275. minWidth: 100,
  276. prop: 'specification',
  277. label: '规格',
  278. align: 'center',
  279. slot: 'specification'
  280. },
  281. {
  282. minWidth: 100,
  283. prop: 'totalCount',
  284. label: '数量',
  285. align: 'center',
  286. slot: 'totalCount'
  287. },
  288. {
  289. minWidth: 120,
  290. prop: 'measuringUnit',
  291. label: '计量单位',
  292. align: 'center',
  293. slot: 'measuringUnit'
  294. },
  295. {
  296. minWidth: 100,
  297. prop: 'singlePrice',
  298. label: '单价',
  299. align: 'center',
  300. slot: 'singlePrice'
  301. },
  302. {
  303. minWidth: 100,
  304. prop: 'totalPrice',
  305. label: '金额',
  306. align: 'center',
  307. slot: 'totalPrice'
  308. }
  309. ],
  310. };
  311. },
  312. methods: {
  313. remove(tableIndex, lineIndex, delType) {
  314. let params = {
  315. tableIndex,
  316. lineIndex,
  317. delType
  318. }
  319. this.$emit('handleRemove', params)
  320. },
  321. getSummaries(param) {
  322. const {columns, data} = param;
  323. const sums = [];
  324. let fields = ['totalPrice', 'paidPrice', 'notPaidPrice', 'invoicedPrice', 'notInvoicedPrice','discountTotalPrice']
  325. columns.forEach((column, index) => {
  326. if (index === 0) {
  327. sums[index] = '合计';
  328. return;
  329. }
  330. const values = fields.includes(column.property) ? data.map(item => Number(item[column.property])) : []
  331. if (!values.every(value => isNaN(value))) {
  332. sums[index] = values.reduce((prev, curr) => {
  333. const value = Number(curr);
  334. if (!isNaN(value)) {
  335. return prev + curr;
  336. } else {
  337. return prev;
  338. }
  339. }, 0);
  340. sums[index] = (sums[index]).toFixed(2)
  341. } else {
  342. sums[index] = '';
  343. }
  344. });
  345. return sums;
  346. }
  347. }
  348. };
  349. </script>
  350. <style lang="scss" scoped>
  351. .headbox {
  352. display: flex;
  353. justify-content: space-between;
  354. align-items: center;
  355. .amount {
  356. font-size: 14px;
  357. font-weight: bold;
  358. padding-right: 30px;
  359. }
  360. }
  361. .time-form .el-form-item {
  362. margin-bottom: 0 !important;
  363. }
  364. ::v-deep .period {
  365. display: flex;
  366. .borderleftnone {
  367. .el-input--medium .el-input__inner {
  368. border-top-right-radius: 0;
  369. border-bottom-right-radius: 0;
  370. }
  371. }
  372. .borderrightnone {
  373. .el-input--medium .el-input__inner {
  374. border-top-left-radius: 0;
  375. border-bottom-left-radius: 0;
  376. }
  377. }
  378. }
  379. ::v-deep .time-form tbody > tr:hover > td {
  380. background-color: transparent !important;
  381. }
  382. ::v-deep .time-form .el-table tr {
  383. background-color: #ffffff;
  384. }
  385. .pricebox {
  386. display: flex;
  387. justify-content: flex-start;
  388. align-items: center;
  389. font-weight: bold;
  390. }
  391. </style>