123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <template>
- <a-card :bordered="false">
- <div class="equipmentManagement">
-
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="5" :sm="24">
- <a-form-item label="设备编码">
- <a-input allowClear v-model.trim="queryParam.deviceCode" placeholder="请输入设备编码" />
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="客户名称">
- <storeList ref="storeList" @change="custChange"></storeList>
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="所属省份">
- <a-select id="equipmentManagement-addrProvince" allowClear v-model="queryParam.provinceSn" placeholder="请选择省">
- <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="启用状态">
- <v-select
- v-model="queryParam.enabledFlag"
- ref="auditStatus"
- code="ENABLE_FLAG"
- placeholder="请选择启用状态"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="equipmentManagement-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="equipmentManagement-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <div class="table-operator">
- <a-button type="primary" class="button-error" @click="openModal = true">添加设备</a-button>
- </div>
-
- <s-table
- class="sTable"
- ref="table"
- size="default"
- rowKey="id"
- :columns="columns"
- :data="loadData"
- bordered>
-
- <template slot="addressInfo" slot-scope="text, record">
- <span v-if="record.dealer">{{ record.dealer.provinceName }}{{ record.dealer.cityName }}</span>
- </template>
-
- <template slot="isEnabled" slot-scope="text, record">
- <a-switch checked-children="是" un-checked-children="否" :checked="record.isChecked" @change="handleChecked(record)" />
- </template>
-
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="link" class="button-primary" @click="handleEdit(record)">编辑</a-button>
- <a-button size="small" type="link" class="button-primary" @click="handleDel(record)">删除</a-button>
- </template>
- </s-table>
- </div>
-
- <addEquipmentModal ref="equipmentBox" :openModal="openModal" :itemId="itemId" @confirm="$refs.table.refresh(true)" @close="openModal=false" />
- </a-card>
- </template>
- <script>
- import storeList from '@/views/common/storeList.vue'
- import { STable, VSelect } from '@/components'
- import addEquipmentModal from './addEquipmentModal'
- import { handDeviceList, handDeviceDel, handDeviceEdit } from '@/api/handDevice.js'
- import { getAreaCgj } from '@/api/data'
- export default {
- name: 'EquipmentManagement',
- components: { STable, VSelect, storeList, addEquipmentModal },
- data () {
- return {
- advanced: false,
- disabled: false,
- queryParam: {
- dealerSn: undefined,
- deviceCode: '',
- deviceName: '',
- enabledFlag: undefined,
- provinceSn: undefined
- },
- addrProvinceList: [],
- openModal: false,
- itemId: '',
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
- { title: '设备编码', dataIndex: 'deviceCode', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '设备名称', dataIndex: 'deviceName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '地区', scopedSlots: { customRender: 'addressInfo' }, align: 'center' },
- { title: '经销商', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '是否启用', scopedSlots: { customRender: 'isEnabled' }, align: 'center' },
- { title: '添加时间', dataIndex: 'createDate', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
- ],
-
- loadData: parameter => {
- this.disabled = true
- return handDeviceList(Object.assign(parameter, this.queryParam)).then(res => {
- const data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- data.list[i].isChecked = data.list[i].enabledFlag == 1
- }
- this.disabled = false
- return data
- })
- }
- }
- },
- mounted () {
- this.getCityList()
- },
- methods: {
-
- getCityList () {
- getAreaCgj({ type: '2' }).then(res => {
- if (res.status == 200) {
- this.addrProvinceList = res.data || []
- } else {
- this.addrProvinceList = []
- }
- })
- },
-
- handleChecked (row) {
- const _this = this
- handDeviceEdit({
- id: row.id,
- enabledFlag: row.isChecked ? '0' : '1',
- dealerSn: row.dealerSn,
- deviceCode: row.deviceCode,
- deviceName: row.deviceName
- }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.resetSearchForm()
- }
- })
- },
-
- custChange (val) {
- this.queryParam.dealerSn = val.key
- },
- handleEdit (row) {
- this.itemId = row.id
- this.$nextTick(() => {
- this.openModal = true
- this.$refs.equipmentBox.pageInit()
- })
- },
- handleDel (row) {
- const _this = this
- this.$warning({
- title: '提示',
- content: '删除该设备后,所有绑定数据将被清除,并且不能继续操作。',
- okText: '删除',
- onOk () {
- handDeviceDel({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.resetSearchForm()
- }
- })
- },
- onCancel () {}
- })
- },
-
- dateChange (date) {
- this.queryParam.beginDate = date[0]
- this.queryParam.endDate = date[1]
- },
-
- resetSearchForm () {
- this.queryParam.dealerSn = undefined
- this.queryParam.deviceCode = ''
- this.queryParam.deviceName = ''
- this.queryParam.enabledFlag = undefined
- this.queryParam.provinceSn = undefined
- this.$refs.storeList.resetForm()
- this.$refs.table.refresh(true)
- }
- }
- }
- </script>
- <style lang="less">
- .equipmentManagement{
- .sTable{
- margin-top: 10px;
- }
- }
- </style>
|