boxSetting.vue 6.2 KB

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