ExchangeSetting.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <a-card :bordered="false" class="network-table-page-search-wrapper">
  3. <div class="network-searchForm">
  4. <a-form layout="inline" :form="form" ref="form" v-bind="formItemLayout" @keyup.enter.native="$refs.table.refresh(true)">
  5. <a-row :gutter="48">
  6. <a-col :span="6">
  7. <a-form-item label="箱体类型" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  8. <a-input
  9. id="boxSetting-name"
  10. allowClear
  11. :maxLength="30"
  12. v-model="queryParam.name"
  13. placeholder="请输入箱体类型" />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :span="6">
  17. <a-button class="handle-btn serach-btn" id="boxSetting-btn-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  18. <a-button class="handle-btn" type="" id="boxSetting-btn-reset" @click="handleReset">重置</a-button>
  19. </a-col>
  20. </a-row>
  21. </a-form>
  22. </div>
  23. <div class="table-operator">
  24. <a-button type="primary" icon="plus" @click="openModal" id="roleList-openModal">新增</a-button>
  25. </div>
  26. <s-table
  27. ref="table"
  28. size="default"
  29. :rowKey="(record) => record.id"
  30. :columns="columns"
  31. :data="loadData"
  32. bordered>
  33. <!-- 操作 -->
  34. <template slot="action" slot-scope="text, record">
  35. <a-icon type="edit" title="编辑" class="actionBtn icon-blues" @click="handleEdit(record)" />
  36. <a-icon
  37. type="delete"
  38. title="删除"
  39. class="actionBtn icon-red"
  40. v-if="!record.isEnable"
  41. @click="delect(record)" />
  42. </template>
  43. </s-table>
  44. <!-- 新增/编辑 弹窗 -->
  45. <add-set-modal :visible="openBoxModal" :data="itemData" @refresh="refreshTable" @close="openBoxModal = false"></add-set-modal>
  46. </a-card>
  47. </template>
  48. <script>
  49. import {
  50. STable,
  51. VSelect
  52. } from '@/components'
  53. import AddSetModal from './AddSetModal.vue'
  54. import { getList, deleteExchangeSetting } from '@/api/exchangeSetting.js'
  55. export default {
  56. name: 'Equipment',
  57. components: {
  58. STable,
  59. VSelect,
  60. AddSetModal
  61. },
  62. data () {
  63. return {
  64. form: this.$form.createForm(this),
  65. formItemLayout: {
  66. labelCol: {
  67. span: 7
  68. },
  69. wrapperCol: {
  70. span: 17
  71. }
  72. },
  73. // 查询参数
  74. queryParam: {
  75. name: '' // 箱体类型
  76. },
  77. openBoxModal: false, // 新增/编辑弹窗
  78. boxId: '', // 箱体id
  79. // 表头
  80. columns: [{
  81. title: '序号',
  82. dataIndex: 'no',
  83. width: 80,
  84. align: 'center'
  85. },
  86. {
  87. title: '创建时间',
  88. dataIndex: 'networkName',
  89. width: 200,
  90. align: 'center'
  91. },
  92. {
  93. title: '兑换规则名称',
  94. dataIndex: 'address',
  95. width: 200,
  96. align: 'center'
  97. },
  98. {
  99. title: '兑换规则说明',
  100. dataIndex: 'equipmentNo',
  101. width: 200,
  102. align: 'center'
  103. },
  104. {
  105. title: '兑换规则(投放重量(g)/可兑换乐豆数(个))',
  106. children: [{
  107. title: '废旧衣服',
  108. dataIndex: 'oProportion',
  109. width: 100,
  110. align: 'center'
  111. },
  112. {
  113. title: '废旧塑料',
  114. dataIndex: 'tProportion',
  115. width: 100,
  116. align: 'center'
  117. },
  118. {
  119. title: '废旧金属',
  120. dataIndex: 'tProportion',
  121. width: 100,
  122. align: 'center',
  123. customRender: (record, index) => {
  124. return record.tProportion || '--'
  125. }
  126. },
  127. {
  128. title: '废旧纸张',
  129. dataIndex: 'tProportion',
  130. width: 100,
  131. align: 'center',
  132. customRender: (record, index) => {
  133. return record.tProportion || '--'
  134. }
  135. },
  136. {
  137. title: '有害垃圾',
  138. dataIndex: 'tProportion',
  139. width: 100,
  140. align: 'center',
  141. customRender: (record, index) => {
  142. return record.tProportion || '--'
  143. }
  144. }
  145. ]
  146. },
  147. {
  148. title: '操作',
  149. scopedSlots: {
  150. customRender: 'action'
  151. },
  152. width: 240,
  153. align: 'center'
  154. }
  155. ],
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: parameter => {
  158. return getList(Object.assign(parameter, this.queryParam)).then(res => {
  159. if (res.status == 200) {
  160. const no = (res.data.pageNo - 1) * res.data.pageSize
  161. for (let i = 0; i < res.data.list.length; i++) {
  162. const _item = res.data.list[i]
  163. _item.no = no + i + 1
  164. }
  165. return res.data
  166. }
  167. })
  168. }
  169. }
  170. },
  171. beforeRouteEnter (to, from, next) {
  172. next(vm => {
  173. vm.handleReset()
  174. })
  175. },
  176. methods: {
  177. // 重置
  178. handleReset () {
  179. console.log('重置', this.queryParam)
  180. this.form.resetFields()
  181. this.$refs.table.refresh(true)
  182. },
  183. // 新建
  184. openModal () {
  185. this.openBoxModal = true
  186. this.itemData = {}
  187. },
  188. // 编辑
  189. handleEdit (item) {
  190. this.openBoxModal = true
  191. },
  192. // 删除
  193. delect (row) {
  194. const _this = this
  195. this.$confirm({
  196. title: '警告',
  197. centered: true,
  198. content: '删除后无法恢复,确认删除?',
  199. okText: '确定',
  200. cancelText: '取消',
  201. onOk () {
  202. deleteExchangeSetting({
  203. id: row.id
  204. }).then(res => {
  205. console.log(res, 'res1111')
  206. if (res.status == 200) {
  207. _this.$message.success(res.message)
  208. _this.$refs.table.refresh()
  209. }
  210. })
  211. }
  212. })
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="less" scoped>
  218. .network-table-page-search-wrapper {
  219. .network-searchForm {
  220. .ant-form-inline .ant-form-item {
  221. width: 100%;
  222. }
  223. // 搜索框的下间距
  224. .ant-form-item {
  225. margin-bottom: 10px;
  226. }
  227. .handle-btn {
  228. margin-top: 4px;
  229. }
  230. .serach-btn {
  231. margin-right: 10px;
  232. }
  233. }
  234. .actionBtn {
  235. font-size: 20px;
  236. padding: 0 10px;
  237. }
  238. // 合计
  239. .total {
  240. margin: 15px 0 25px;
  241. width: 100%;
  242. background-color: #e6f7ff;
  243. border: 1px solid #91d5ff;
  244. padding: 8px 15px 8px 27px;
  245. border-radius: 4px;
  246. .iconImg {
  247. color: #1890FF;
  248. margin-right: 10px;
  249. }
  250. }
  251. }
  252. </style>