main.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <el-dialog width="840px" :visible.sync="dialogVisible" :append-to-body="false" :modal-append-to-body="false"
  3. :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" @closed="handleClose"
  4. class="purchasePlan-picker">
  5. <div class="purchasePlan-picker__body">
  6. <div class="purchasePlan-picker__filter">
  7. <div class="filter-item">
  8. <el-input v-model="searchParams.sn" clearable placeholder="请输入入库单号" style="width: 160px" />
  9. </div>
  10. <div class="filter-item">
  11. <el-button type="primary" @click="handleSearch">搜索 </el-button>
  12. </div>
  13. </div>
  14. <el-table ref="purchasePlanTable" v-loading="loading" :data="purchasePlanData.data" border row-key="id"
  15. @selection-change="handleSelectionChange" @row-click="handleRowClick" max-height="400" style="width: 100%; min-height: 400px">
  16. <el-table-column v-if="limit === 1" label="选择" width="55" align="center">
  17. <template slot-scope="scope">
  18. <el-radio v-model="radioGuide" :label="scope.row"
  19. :disabled="selectedIds.some(v => v === scope.row.id)"><i></i></el-radio>
  20. </template>
  21. </el-table-column>
  22. <el-table-column v-else type="selection" label="选择" width="55" :selectable="checkDisable" reserve-selection
  23. align="center" />
  24. <el-table-column label="入库单号" width="150">
  25. <template slot-scope="scope">
  26. {{ scope.row.sn }}
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="入库时间" width="150">
  30. <template slot-scope="scope">
  31. {{ scope.row.entry_time | unixToDate }}
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="供应商" width="150">
  35. <template slot-scope="scope">
  36. {{ scope.row.supplier_name }}
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="部门名称" width="150">
  40. <template slot-scope="scope">
  41. {{ scope.row.dept_name }}
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="仓库" width="150">
  45. <template slot-scope="scope">
  46. {{ scope.row.warehouse_name }}
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <div class="purchasePlan-picker__tools">
  51. <div class="tools">
  52. </div>
  53. <el-pagination v-if="purchasePlanData.data_total" background :page-sizes="[10, 30, 50, 100]"
  54. :total="purchasePlanData.data_total" layout="total, sizes, prev, next, pager, jumper"
  55. @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  56. </div>
  57. </div>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button @click="handleCancel">取 消</el-button>
  60. <el-button type="primary" @click="handleConfirm">确 定</el-button>
  61. </span>
  62. </el-dialog>
  63. </template>
  64. <script>
  65. import * as DefaultOptions from './defaultOptions'
  66. import request from '@/utils/request'
  67. export default {
  68. name: 'EnPurchasePlan',
  69. props: {
  70. ...DefaultOptions.props
  71. },
  72. data() {
  73. return {
  74. ...DefaultOptions.data,
  75. dialogVisible: false,
  76. selected: [],
  77. radioGuide: '',
  78. purchasePlanParams: {
  79. page_no: 1,
  80. page_size: 10
  81. },
  82. searchParams: {
  83. sn: ''
  84. },
  85. purchasePlanData: {
  86. data: [],
  87. data_total: 0
  88. },
  89. // 加载采购计划列表
  90. loading: false
  91. }
  92. },
  93. mounted() {
  94. this.getGoodsList()
  95. },
  96. watch: {
  97. show: {
  98. immediate: true,
  99. handler(newVal) {
  100. this.$nextTick(() => {
  101. this.dialogVisible = newVal
  102. })
  103. }
  104. }
  105. },
  106. methods: {
  107. checkDisable(row, index) {
  108. return this.selectedIds.some(v => v === row.id) ? 0 : 1
  109. },
  110. // 关闭
  111. handleClose() {
  112. this.$nextTick(this.close)
  113. this.dialogVisible = false
  114. this.$emit('closed')
  115. },
  116. // 取消
  117. handleCancel() {
  118. this.dialogVisible = false
  119. this.$emit('cancel')
  120. typeof this.reject === 'function' && this.reject('取消了')
  121. },
  122. // 确认
  123. handleConfirm() {
  124. if (this.limit === 1) {
  125. if (!this.radioGuide) return this.$message.error('请选择采购计划')
  126. } else {
  127. if (!this.selected.length) return this.$message.error('请选择采购计划')
  128. }
  129. this.dialogVisible = false
  130. let purchasePlans = this.limit === 1 ? [this.radioGuide] : this.selected
  131. purchasePlans = JSON.parse(JSON.stringify(purchasePlans))
  132. this.$emit('confirm', purchasePlans)
  133. typeof this.resolve === 'function' && this.resolve(purchasePlans)
  134. this.$emit('close')
  135. },
  136. // 选择
  137. handleSelectionChange(val) {
  138. this.selected = val
  139. },
  140. // 分页大小发生改变
  141. handleSizeChange(size) {
  142. goods
  143. this.purchasePlanParams.page_size = size
  144. this.getGoodsList()
  145. },
  146. // 当前页数发生改版
  147. handleCurrentChange(current) {
  148. this.purchasePlanParams.page_no = current
  149. this.getGoodsList()
  150. },
  151. // 搜索
  152. handleSearch() {
  153. this.purchasePlanParams.page_no = 1
  154. this.purchasePlanParams = {
  155. ...this.purchasePlanParams,
  156. ...this.searchParams
  157. }
  158. this.getGoodsList()
  159. },
  160. // 点击了某行
  161. handleRowClick(row) {
  162. if (this.limit === 1) {
  163. this.radioGuide = row
  164. } else {
  165. this.$refs.purchasePlanTable.toggleRowSelection(row)
  166. }
  167. },
  168. // 获取采购计划列表
  169. async getGoodsList() {
  170. this.loading = true
  171. const params = JSON.parse(JSON.stringify(this.purchasePlanParams))
  172. request({
  173. url: this.goodsApi,
  174. method: 'get',
  175. loading: false,
  176. params: {
  177. ...params,
  178. ...this.purchasePlanApiParams,
  179. }
  180. }).then(response => {
  181. this.loading = false
  182. this.purchasePlanData = response
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .purchasePlan-picker {
  190. clear: both;
  191. .purchasePlan-picker__filter {
  192. float: right;
  193. }
  194. /deep/ {
  195. .el-dialog__body {
  196. padding-top: 20px;
  197. padding-bottom: 20px;
  198. }
  199. .el-dialog__header {
  200. padding: 9px 20px 10px;
  201. border-bottom: 1px solid #e5e5e5;
  202. text-shadow: 0 1px 0 #fff;
  203. background-color: #efefef;
  204. }
  205. .el-dialog__footer {
  206. border-top: solid 1px #e5e5e5;
  207. background: #f5f5f5;
  208. }
  209. .el-table .el-table__body-wrapper .el-table__row {
  210. cursor: pointer;
  211. }
  212. }
  213. &__filter {
  214. display: flex;
  215. align-items: center;
  216. background-color: #fff;
  217. border-right: none;
  218. position: relative;
  219. margin-bottom: 10px;
  220. .filter-item {
  221. display: flex;
  222. align-items: center;
  223. }
  224. .filter-item+.filter-item {
  225. margin-left: 10px;
  226. }
  227. .filter-item:last-child {
  228. flex: 1;
  229. margin-left: 20px;
  230. /deep/ .el-button {
  231. width: 100%;
  232. max-width: 120px;
  233. font-weight: bold;
  234. }
  235. }
  236. }
  237. &__body {
  238. max-height: 650px;
  239. overflow: hidden auto;
  240. }
  241. &__tools {
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. margin-top: 10px;
  246. .tools {
  247. display: flex;
  248. }
  249. }
  250. }
  251. </style>