product-list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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?find(optionsState, function(o) { return o.code == scope.row.state }).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. import find from 'lodash/find'
  90. export default {
  91. name: 'product-list',
  92. components: {Detail},
  93. props: {
  94. // 默认第一页的数据
  95. defaultList: {
  96. type: Array,
  97. default: []
  98. },
  99. // 任务单编码
  100. productCode: {
  101. type: String,
  102. default: ''
  103. },
  104. defaultTotalPage: {
  105. type: [Number, String],
  106. default: 0
  107. }
  108. },
  109. data () {
  110. return {
  111. detailsVisible: false,
  112. dataForm: {},
  113. dataList: this.defaultList,
  114. pageIndex: 1,
  115. pageSize: 10,
  116. totalPage: Number(this.defaultTotalPage),
  117. dataListLoading: false,
  118. dataListSelections: [],
  119. // 状态:1:待排产,2:生产中,3:生产完成
  120. optionsState: [
  121. {
  122. code: '1',
  123. value: '待排产'
  124. },
  125. {
  126. code: '2',
  127. value: '生产中'
  128. },
  129. {
  130. code: '3',
  131. value: '生产完成'
  132. },
  133. {
  134. code: '5',
  135. value: '报废'
  136. }
  137. ]
  138. }
  139. },
  140. created () {
  141. },
  142. methods: {
  143. onChose () {
  144. this.$emit('onChose')
  145. },
  146. onChildClose () {
  147. this.detailsVisible = false
  148. },
  149. // 查询
  150. queryPage () {
  151. this.pageIndex = 1
  152. this.getDataList()
  153. },
  154. // 获取数据列表
  155. getDataList () {
  156. this.dataListLoading = true
  157. let params = {
  158. 'current': this.pageIndex,
  159. 'size': this.pageSize,
  160. 'prodCode': this.productCode
  161. }
  162. getProductByCode(params).then(({data}) => {
  163. if (data && data.code === '200') {
  164. this.dataList = data.data.records
  165. this.totalPage = Number(data.data.total)
  166. } else {
  167. this.dataList = []
  168. this.totalPage = 0
  169. }
  170. console.log('monitor')
  171. this.dataListLoading = false
  172. })
  173. },
  174. // 每页数
  175. sizeChangeHandle (val) {
  176. this.pageSize = val
  177. this.pageIndex = 1
  178. this.getDataList()
  179. },
  180. // 当前页
  181. currentChangeHandle (val) {
  182. this.pageIndex = val
  183. this.getDataList()
  184. },
  185. // 多选
  186. selectionChangeHandle (val) {
  187. this.dataListSelections = val
  188. },
  189. // 新增 / 修改
  190. detail (id, prodCode, disable) {
  191. this.detailsVisible = true
  192. this.$nextTick(() => {
  193. this.$refs.details.init(id, prodCode, disable)
  194. })
  195. },
  196. // 创建新物料
  197. createNewProduct () {
  198. this.$message.warning('功能暂未开放')
  199. },
  200. closeDialogEvent () {
  201. this.detailsVisible = false
  202. },
  203. find
  204. }
  205. }
  206. </script>
  207. <style scoped>
  208. </style>