index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :columnParsing="columnParsing"
  7. :optionsEvensGroup="optionsEvensGroup"
  8. :tableAttributes="tableAttributes"
  9. :tableEvents="tableEvents"
  10. >
  11. <center-parts-shop-in-stock-from
  12. v-if="showFromBool"
  13. @goBack="showFromBool = false"
  14. @success="$refs.pageRef.refreshList"
  15. />
  16. </template-page>
  17. </template>
  18. <script>
  19. import TemplatePage from '@/components/template/template-page-1.vue'
  20. import import_mixin from '@/components/template/import_mixin.js'
  21. import CenterPartsShopInStockFrom from '../components/center-parts-shop-in-stock-from.vue'
  22. import {
  23. partsNewInList,
  24. partsNewInExport,
  25. partsNewInImport,
  26. partsNewInUpdate,
  27. partsNewInDel
  28. } from '@/api/material-system/center/center-parts-shop-in-stock'
  29. import operation_mixin from '@/components/template/operation_mixin.js'
  30. export default {
  31. components: { TemplatePage, CenterPartsShopInStockFrom },
  32. mixins: [import_mixin, operation_mixin],
  33. data() {
  34. return {
  35. // 表格属性
  36. tableAttributes: {
  37. selectColumn: true,
  38. selectable: this.selectable
  39. },
  40. // 表格事件
  41. tableEvents: {
  42. 'selection-change': this.selectionChange
  43. },
  44. recordSelected: [],
  45. showFromBool: false
  46. }
  47. },
  48. computed: {
  49. optionsEvensGroup() {
  50. return [
  51. [
  52. [
  53. this.optionsEvensAuth('partsStorage', {
  54. click: this.update
  55. })
  56. ]
  57. ],
  58. [
  59. [
  60. this.optionsEvensAuth('add', {
  61. click: this.add
  62. })
  63. ]
  64. ],
  65. [
  66. [
  67. this.optionsEvensAuth('dels', {
  68. click: this.del
  69. })
  70. ]
  71. ],
  72. [
  73. [
  74. this.optionsEvensAuth('import', ({ moduleName }) => {
  75. return {
  76. name: moduleName,
  77. render: () => {
  78. return this.importButton(partsNewInImport, moduleName)
  79. }
  80. }
  81. })
  82. ]
  83. ]
  84. ]
  85. }
  86. },
  87. methods: {
  88. // 列表请求函数
  89. getList(...p) {
  90. this.recordSelected = []
  91. return partsNewInList(...p)
  92. },
  93. // 列表导出函数
  94. exportList: partsNewInExport,
  95. // 表格列解析渲染数据更改
  96. columnParsing(item, defaultData) {
  97. return defaultData
  98. },
  99. // 获取勾选框数据
  100. selectionChange(data) {
  101. this.recordSelected = data
  102. },
  103. // 设置勾选框禁用项
  104. selectable(row, index) {
  105. if (row.status === 'CHECKED') {
  106. return false
  107. }
  108. return true
  109. },
  110. add() {
  111. this.showFromBool = true
  112. },
  113. update() {
  114. if (this.recordSelected.length) {
  115. this.$confirm('请确认配件是否已收货?', '提示', {
  116. confirmButtonText: '确定',
  117. cancelButtonText: '取消',
  118. type: 'warning'
  119. })
  120. .then(() => {
  121. partsNewInUpdate({
  122. ids: this.recordSelected.map(item => item.id).join(',')
  123. })
  124. .then(res => {
  125. this.$refs.pageRef.refreshList()
  126. this.$message({
  127. type: 'success',
  128. message: '操作成功!'
  129. })
  130. })
  131. .catch(() => {
  132. this.$message({
  133. type: 'error',
  134. message: '操作失败!'
  135. })
  136. })
  137. })
  138. .catch(() => {
  139. this.$message({
  140. type: 'info',
  141. message: '已取消操作'
  142. })
  143. })
  144. } else {
  145. this.$message({
  146. type: 'info',
  147. message: '请先勾选需要操作的数据!'
  148. })
  149. }
  150. },
  151. del() {
  152. if (this.recordSelected.length) {
  153. this.$confirm('此操作将删除数据, 是否继续?', '提示', {
  154. confirmButtonText: '确定',
  155. cancelButtonText: '取消',
  156. type: 'warning'
  157. })
  158. .then(() => {
  159. partsNewInDel({
  160. ids: this.recordSelected.map(item => item.id).join(',')
  161. })
  162. .then(res => {
  163. this.$refs.pageRef.refreshList()
  164. this.$message({
  165. type: 'success',
  166. message: '删除成功!'
  167. })
  168. })
  169. .catch(() => {
  170. this.$message({
  171. type: 'error',
  172. message: '删除失败'
  173. })
  174. })
  175. })
  176. .catch(() => {
  177. this.$message({
  178. type: 'info',
  179. message: '已取消删除'
  180. })
  181. })
  182. } else {
  183. this.$message({
  184. type: 'info',
  185. message: '请先勾选需要删除的数据!'
  186. })
  187. }
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped></style>