purchase.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <!-- 产品管理 -->
  2. <template>
  3. <div class="purchase">
  4. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  5. <el-form-item label="说明">
  6. <el-input v-model="dataForm.notes" placeholder="说明" clearable/>
  7. </el-form-item>
  8. <el-form-item label="类别">
  9. <el-select
  10. v-model="dataForm.purchaseType"
  11. remote
  12. placeholder="请选择">
  13. <el-option
  14. v-for="item in optionsType"
  15. :key="item.code"
  16. :label="item.value"
  17. :value="item.code">
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="申请日期">
  22. <el-date-picker
  23. v-model="dataForm.applyDate"
  24. value-format="yyyy-MM-dd"
  25. type="date">
  26. </el-date-picker>
  27. </el-form-item>
  28. <el-form-item label="状态">
  29. <el-select
  30. v-model="dataForm.purchaseState"
  31. remote
  32. placeholder="请选择">
  33. <el-option
  34. v-for="item in optionsState"
  35. :key="item.code"
  36. :label="item.value"
  37. :value="item.code">
  38. </el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button @click="search()">查询</el-button>
  43. <el-button type="primary" @click="addOrUpdateHandle(0, false)">创建新产品</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <el-table
  47. :data="dataList"
  48. border
  49. v-loading="dataListLoading"
  50. style="width: 100%;">
  51. <el-table-column
  52. label="序号"
  53. type="index"
  54. width="50"
  55. align="center">
  56. </el-table-column>
  57. <el-table-column
  58. prop="purchaseCode"
  59. header-align="center"
  60. align="center"
  61. min-width="100"
  62. label="采购编码">
  63. </el-table-column>
  64. <el-table-column
  65. prop="materialName"
  66. header-align="center"
  67. align="center"
  68. min-width="120"
  69. label="物品名称">
  70. </el-table-column>
  71. <el-table-column
  72. prop="purchaseType"
  73. header-align="center"
  74. align="center"
  75. :formatter="formatType"
  76. label="采购类别">
  77. </el-table-column>
  78. <el-table-column
  79. prop="createTime"
  80. header-align="center"
  81. align="center"
  82. min-width="160"
  83. label="申请时间">
  84. </el-table-column>
  85. <el-table-column
  86. prop="applierName"
  87. header-align="center"
  88. align="center"
  89. min-width="100"
  90. label="申请人">
  91. </el-table-column>
  92. <el-table-column
  93. prop="deptName"
  94. header-align="center"
  95. align="center"
  96. min-width="100"
  97. label="申请部门">
  98. </el-table-column>
  99. <el-table-column
  100. prop="notes"
  101. header-align="center"
  102. align="center"
  103. min-width="180"
  104. :show-overflow-tooltip="true"
  105. label="说明">
  106. </el-table-column>
  107. <el-table-column
  108. prop="purchaseState"
  109. header-align="center"
  110. align="center"
  111. :formatter="formatState"
  112. label="当前状态">
  113. </el-table-column>
  114. <el-table-column
  115. fixed="right"
  116. header-align="center"
  117. align="center"
  118. width="150"
  119. label="操作">
  120. <template slot-scope="scope">
  121. <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.purchaseId, true)">查看</el-button>
  122. <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.purchaseId, false)">编辑</el-button>
  123. <el-button style="color: red" type="text" size="small" @click="revokeHandle(scope.row.purchaseId)">撤回</el-button>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. <el-pagination
  128. @size-change="sizeChangeHandle"
  129. @current-change="currentChangeHandle"
  130. :current-page="pageIndex"
  131. :page-sizes="[10, 20, 50, 100]"
  132. :page-size="pageSize"
  133. :total="totalPage"
  134. layout="total, sizes, prev, pager, next, jumper">
  135. </el-pagination>
  136. <!-- 弹窗, 新增 / 修改 -->
  137. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  138. </div>
  139. </template>
  140. <script>
  141. import AddOrUpdate from './purchase-add-or-update'
  142. import { getDictList } from '@/api/dict'
  143. import { getPurchaseList, revokePurchase } from '@/api/sale'
  144. export default {
  145. name: 'purchase',
  146. components: {
  147. AddOrUpdate
  148. },
  149. data () {
  150. return {
  151. addOrUpdateVisible: false,
  152. dataForm: {},
  153. dataList: [],
  154. pageIndex: 1,
  155. pageSize: 10,
  156. totalPage: 0,
  157. dataListLoading: false,
  158. dataListSelections: [],
  159. optionsType: [],
  160. optionsState: [
  161. {
  162. code: '0',
  163. value: '未审批'
  164. },
  165. {
  166. code: '1',
  167. value: '审批通过'
  168. }
  169. ]
  170. }
  171. },
  172. created () {
  173. this.getTypeList()
  174. this.getDataList()
  175. },
  176. methods: {
  177. // 获取采购类别字典
  178. getTypeList () {
  179. getDictList({type: 'purchase_type'}).then(({data}) => {
  180. if (data) {
  181. this.optionsType = data
  182. }
  183. })
  184. },
  185. // 查询
  186. search () {
  187. this.pageIndex = 1
  188. this.getDataList()
  189. },
  190. // 获取数据列表
  191. getDataList () {
  192. this.dataListLoading = true
  193. this.addOrUpdateVisible = false
  194. let params = {
  195. 'current': this.pageIndex,
  196. 'size': this.pageSize,
  197. 'applyDate': this.dataForm.applyDate ? this.dataForm.applyDate : null,
  198. 'notes': this.dataForm.notes ? this.dataForm.notes : null,
  199. 'purchaseState': this.dataForm.purchaseState ? this.dataForm.purchaseState : null,
  200. 'purchaseType': this.dataForm.purchaseType ? this.dataForm.purchaseType : null
  201. }
  202. getPurchaseList(params).then(({data}) => {
  203. if (data && data.code === '200') {
  204. this.dataList = data.data.records
  205. this.totalPage = Number(data.data.total)
  206. } else {
  207. this.dataList = []
  208. this.totalPage = 0
  209. }
  210. this.dataListLoading = false
  211. })
  212. },
  213. revokeHandle (id) {
  214. if (!id) return
  215. let data = {id: id}
  216. this.$confirm(`确定撤回?`, '提示', {
  217. confirmButtonText: '确定',
  218. cancelButtonText: '取消',
  219. type: 'warning'
  220. }).then(() => {
  221. revokePurchase(data).then(({data}) => {
  222. if (data && data.code === '200') {
  223. this.$message({
  224. message: '操作成功',
  225. type: 'success',
  226. duration: 1500,
  227. onClose: () => {
  228. this.getDataList()
  229. }
  230. })
  231. } else {
  232. this.$message.error(data.msg)
  233. }
  234. })
  235. }).catch(() => {})
  236. },
  237. // 每页数
  238. sizeChangeHandle (val) {
  239. this.pageSize = val
  240. this.pageIndex = 1
  241. this.getDataList()
  242. },
  243. // 当前页
  244. currentChangeHandle (val) {
  245. this.pageIndex = val
  246. this.getDataList()
  247. },
  248. // 多选
  249. selectionChangeHandle (val) {
  250. this.dataListSelections = val
  251. },
  252. // 新增 / 修改
  253. addOrUpdateHandle (id, disable) {
  254. this.addOrUpdateVisible = true
  255. this.$nextTick(() => {
  256. this.$refs.addOrUpdate.init(id, disable)
  257. })
  258. },
  259. // 转换属性“类别”
  260. formatType (row) {
  261. if (this.optionsType && row.purchaseType) {
  262. const item1 = this.optionsType.find((item) => item.code === row.purchaseType.toString())
  263. return item1 ? item1.value : ''
  264. }
  265. },
  266. // 转换属性“是否组合产品”
  267. formatState (row) {
  268. if (!row.purchaseState) return ''
  269. const item1 = this.optionsState.find((item) => item.code === row.purchaseState.toString())
  270. return item1 ? item1.value : ''
  271. }
  272. }
  273. }
  274. </script>
  275. <style scoped>
  276. </style>