wuliaoList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div>
  3. <a-table
  4. ref="table"
  5. size="middle"
  6. :scroll="{x:true}"
  7. bordered
  8. rowKey="id"
  9. :columns="columns"
  10. :dataSource="dataSource"
  11. :pagination="ipagination"
  12. :loading="loading"
  13. class="j-table-force-nowrap"
  14. @change="handleTableChange">
  15. </a-table>
  16. </div>
  17. </template>
  18. <script>
  19. import '@/assets/less/TableExpand.less'
  20. import { mixinDevice } from '@/utils/mixin'
  21. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  22. import { getDbClList } from '@/api/kzksApi.js'
  23. var columns = [
  24. {
  25. title: '序号',
  26. dataIndex: '',
  27. key:'rowIndex',
  28. width:60,
  29. align:"center",
  30. customRender:function (t,r,index) {
  31. return parseInt(index)+1;
  32. },
  33. fixed:"left",
  34. },
  35. {
  36. title: '规格型号',
  37. dataIndex: 'ggxh',
  38. width: 100,
  39. align: 'center',
  40. fixed:"left",
  41. },
  42. {
  43. title: '物料编码',
  44. dataIndex: 'wlbm',
  45. // width: 100,
  46. align: 'center',
  47. },
  48. {
  49. title: '物料名称',
  50. dataIndex: 'wlmc',
  51. // width: 100,
  52. align: 'center'
  53. },
  54. ]
  55. export default {
  56. mixins:[JeecgListMixin, mixinDevice],
  57. // props: {
  58. // // 对比表格数据
  59. // // duibiclList: {
  60. // // type: Array,
  61. // // default: ()=>{},
  62. // // required: false
  63. // // }
  64. // chooseRowType: {
  65. // type: Number,
  66. // default: 1
  67. // },
  68. // duibiTasknos: {
  69. // type: String,
  70. // default: ''
  71. // }
  72. // },
  73. props: ['chooseRowType', 'duibiTasknos'],
  74. data() {
  75. return {
  76. name: '',
  77. dataSource: [],
  78. // 表头
  79. columns: []
  80. };
  81. },
  82. created(){
  83. },
  84. methods: {
  85. // 数据处理
  86. loadData(arg){
  87. // console.log(this.duibiTasknos)
  88. this.dataSource = []
  89. var params = {
  90. tasknos: this.duibiTasknos,
  91. pageNo: this.ipagination.current,
  92. pageSize: this.ipagination.pageSize,
  93. }
  94. getDbClList(params).then((res) => {
  95. // console.log(res)
  96. // console.log(this.columns)
  97. if(res.success){
  98. // 分页
  99. if(res.result.total) {
  100. this.ipagination.total = res.result.total;
  101. } else {
  102. this.ipagination.total = 0;
  103. }
  104. // 处理数据
  105. var arrList = res.result.records
  106. // 头部
  107. this.columns = [...columns]
  108. arrList[0].taskVoList.forEach(item => {
  109. this.columns.push({
  110. title: item.taskno,
  111. // dataIndex: Object.keys(item)[1],
  112. children: [
  113. {
  114. title: '是否含有',
  115. align: 'center',
  116. width: 100,
  117. dataIndex: 'flag_' + item.taskno,
  118. },
  119. {
  120. title: '实发总数量',
  121. align: 'center',
  122. dataIndex: 'totalCount_' + item.taskno,
  123. },
  124. {
  125. title: '归一化单价(元)',
  126. align: 'center',
  127. dataIndex: 'unitPrice_' + item.taskno,
  128. customCell: this.setCustomCell,
  129. }
  130. ]
  131. })
  132. });
  133. // 表格数据处理
  134. arrList.forEach(item=>{
  135. // console.log(item)
  136. var objItem = {}
  137. objItem.id = item.id
  138. objItem.ggxh = item.ggxh
  139. objItem.wlbm = item.wlbm
  140. objItem.wlmc = item.wlmc
  141. objItem.equal = item.equal
  142. item.taskVoList.forEach(ele=>{
  143. // console.log(ele)
  144. objItem['flag_'+ele.taskno] = ele.flag==='yes'?'√':'×'
  145. objItem['totalCount_'+ele.taskno] = ele.totalCount?ele.totalCount:'-'
  146. objItem['unitPrice_'+ele.taskno] = ele.unitPrice?ele.unitPrice:'-'
  147. })
  148. // console.log(objItem)
  149. this.dataSource.push(objItem)
  150. })
  151. // console.log(this.dataSource)
  152. }else{
  153. this.$message.warning(res.message)
  154. }
  155. }).finally(() => {
  156. this.loading = false
  157. })
  158. },
  159. // handleTableChange(pagination, filters, sorter) {
  160. // //分页、排序、筛选变化时触发
  161. // //TODO 筛选
  162. // console.log(pagination)
  163. // if (Object.keys(sorter).length > 0) {
  164. // this.isorter.column = sorter.field;
  165. // this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
  166. // }
  167. // this.ipagination = pagination;
  168. // this.loadData(2);
  169. // },
  170. setCustomCell(record, index){
  171. // console.log(record, index)
  172. // var arr = []
  173. // for (const item in record) {
  174. // if(item.includes('unitPrice')){
  175. // console.log(record[item])
  176. // arr.push(record[item])
  177. // }
  178. // }
  179. // console.log(arr)
  180. if(!record.equal){
  181. return {
  182. style: {
  183. 'color': '#ff1832',
  184. // 'color': '#1890ff',
  185. },
  186. }
  187. }
  188. },
  189. }
  190. };
  191. </script>