product-list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <!-- 产品追溯列表 -->
  2. <template>
  3. <div class="product-list">
  4. <div class="my-title" v-if="!detailsVisible">产品追溯</div>
  5. <template v-if="!detailsVisible">
  6. <el-table
  7. :data="dataList"
  8. border
  9. v-loading="dataListLoading"
  10. style="width: 100%;">
  11. <el-table-column
  12. label="序号"
  13. type="index"
  14. width="50"
  15. align="center">
  16. </el-table-column>
  17. <el-table-column
  18. prop="productName"
  19. header-align="center"
  20. align="center"
  21. min-width="140"
  22. :show-tooltip-when-overflow="true"
  23. label="产品名称">
  24. </el-table-column>
  25. <el-table-column
  26. prop="prodCode"
  27. header-align="center"
  28. align="center"
  29. min-width="100"
  30. :show-tooltip-when-overflow="true"
  31. label="产品编号">
  32. </el-table-column>
  33. <el-table-column
  34. prop="orderCode"
  35. header-align="center"
  36. align="center"
  37. min-width="140"
  38. :show-tooltip-when-overflow="true"
  39. label="订单编号">
  40. </el-table-column>
  41. <el-table-column
  42. prop="customerName"
  43. header-align="center"
  44. align="center"
  45. min-width="160"
  46. :show-tooltip-when-overflow="true"
  47. label="客户名称">
  48. </el-table-column>
  49. <el-table-column
  50. prop="state"
  51. header-align="center"
  52. align="center"
  53. label="状态">
  54. <template slot-scope="scope">
  55. <span>{{scope.row.state?optionsState[Number(scope.row.state) - 3].value:''}}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. fixed="right"
  60. header-align="center"
  61. align="center"
  62. width="150"
  63. label="操作">
  64. <template slot-scope="scope">
  65. <el-button v-if="isAuth('trace:search:prod:detail')" type="text" size="small" @click="detail(scope.row.id, scope.row.prodCode, true)">查看</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination
  70. @size-change="sizeChangeHandle"
  71. @current-change="currentChangeHandle"
  72. :current-page="pageIndex"
  73. :page-sizes="[10, 20, 50, 100]"
  74. :page-size="pageSize"
  75. :total="totalPage"
  76. layout="total, sizes, prev, pager, next, jumper">
  77. </el-pagination>
  78. <span slot="footer" class="dialog-footer">
  79. <el-button @click="onChose">返回</el-button>
  80. </span>
  81. </template>
  82. <!-- 弹窗, 查看 -->
  83. <detail v-if="detailsVisible" ref="details" @onChose="onChildClose"/>
  84. </div>
  85. </template>
  86. <script>
  87. import Detail from './product-detail'
  88. import { getProductByCode } from '@/api/trace'
  89. export default {
  90. name: 'product-list',
  91. components: {Detail},
  92. props: {
  93. // 默认第一页的数据
  94. defaultList: {
  95. type: Array,
  96. default: []
  97. },
  98. // 订单编码
  99. productCode: {
  100. type: String,
  101. default: ''
  102. },
  103. defaultTotalPage: {
  104. type: [Number, String],
  105. default: 0
  106. }
  107. },
  108. data () {
  109. return {
  110. detailsVisible: false,
  111. dataForm: {},
  112. dataList: this.defaultList,
  113. pageIndex: 1,
  114. pageSize: 10,
  115. totalPage: Number(this.defaultTotalPage),
  116. dataListLoading: false,
  117. dataListSelections: [],
  118. // 状态:1:待排产,2:生产中,3:生产完成
  119. optionsState: [
  120. {
  121. code: '1',
  122. value: '待排产'
  123. },
  124. {
  125. code: '2',
  126. value: '生产中'
  127. },
  128. {
  129. code: '3',
  130. value: '生产完成'
  131. }
  132. ]
  133. }
  134. },
  135. created () {
  136. },
  137. methods: {
  138. onChose () {
  139. this.$emit('onChose')
  140. },
  141. onChildClose () {
  142. this.detailsVisible = false
  143. },
  144. // 查询
  145. queryPage () {
  146. this.pageIndex = 1
  147. this.getDataList()
  148. },
  149. // 获取数据列表
  150. getDataList () {
  151. this.dataListLoading = true
  152. let params = {
  153. 'current': this.pageIndex,
  154. 'size': this.pageSize,
  155. 'prodCode': this.productCode
  156. }
  157. getProductByCode(params).then(({data}) => {
  158. if (data && data.code === '200') {
  159. this.dataList = data.data.records
  160. this.totalPage = Number(data.data.total)
  161. } else {
  162. this.dataList = []
  163. this.totalPage = 0
  164. }
  165. console.log('monitor')
  166. this.dataListLoading = false
  167. })
  168. },
  169. // 每页数
  170. sizeChangeHandle (val) {
  171. this.pageSize = val
  172. this.pageIndex = 1
  173. this.getDataList()
  174. },
  175. // 当前页
  176. currentChangeHandle (val) {
  177. this.pageIndex = val
  178. this.getDataList()
  179. },
  180. // 多选
  181. selectionChangeHandle (val) {
  182. this.dataListSelections = val
  183. },
  184. // 新增 / 修改
  185. detail (id, prodCode, disable) {
  186. this.detailsVisible = true
  187. this.$nextTick(() => {
  188. this.$refs.details.init(id, prodCode, disable)
  189. })
  190. },
  191. // 创建新产品
  192. createNewProduct () {
  193. this.$message.warning('功能暂未开放')
  194. },
  195. closeDialogEvent () {
  196. this.detailsVisible = false
  197. }
  198. }
  199. }
  200. </script>
  201. <style scoped>
  202. </style>