123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921 |
- <template>
- <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
- <a-row :gutter="48" slot="extra">
- <a-col :md="48" :sm="48">
- <span class="table-page-search-submitButtons" style="float: right" >
- <a-button style="margin-left: 8px" type="primary" @click="save()">保存</a-button>
- <a-button style="margin-left: 8px" @click="handleCancel()">返回列表</a-button>
- </span>
- </a-col>
- </a-row>
- <a-form :form="form">
- <a-form-item v-show="false" >
- <a-input v-decorator="['id']" type="hidden"/>
- <a-input v-decorator="['sbId']" type="hidden"/>
- <a-input v-decorator="['typeId']" type="hidden"/>
- </a-form-item>
- <a-form-item v-show="false" >
- <a-input v-decorator="['unit']" type="hidden"/>
- </a-form-item>
- <a-form-item v-show="false" >
- <a-input v-decorator="['unitBz']" type="hidden"/>
- </a-form-item>
- <a-form-item v-show="false">
- <a-input v-decorator="['producerId']" />
- </a-form-item>
- <a-form-item v-show="false">
- <a-input v-decorator="['supplierId']" />
- </a-form-item>
- <title-divider title="基础信息" width="100px"></title-divider>
- <row-list :col="2">
- <row-item>
- <a-form-item
- label="类别"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-tree-select
- style="width: 100%"
- :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
- :treeData="spareTypeData"
- :treeNodeFilterProp="'title'"
- :showSearch="true"
- v-decorator="['parentTypeId', {rules: [{required: true, message: '类别不能为空'}]}]"
- placeholder="请选择"
- >
- </a-tree-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="备件名称"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['name', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="规格型号"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['ggxh']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="生产商"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- style="width: 70%"
- disabled
- v-decorator="['producerName']" />
- <a-button style="width: 30%" type="primary" @click="handleProducerSelect">选择</a-button>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="备件价值"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input-number
- style="width: 100%"
- :min="0"
- :step="0.01"
- :formatter="BaseTool.Amount.formatter"
- :parser="BaseTool.Amount.parser"
- v-decorator="['initialValue', {rules: [{required: true, message: '备件价值不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="采购供应商"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- style="width: 70%"
- disabled
- v-decorator="['supplierName']" />
- <a-button style="width: 30%" type="primary" @click="handleSupplierSelect">选择</a-button>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="备件编号"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['no', {rules: [{required: false, message: '备件编码不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="原厂编号"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- style="width: 100%"
- v-decorator="['initNo']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="自编号"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['zbh', {rules: [{required: false, message: '自编号不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="助记码"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['zjm']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="备件等级"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['level', {initialValue: 1}]" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in levelMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="计量单位"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select
- show-search
- :value="unitName"
- :default-active-first-option="false"
- :show-arrow="true"
- :filter-option="true"
- :not-found-content="null"
- @search="handleSearch"
- @blur="handleBlur"
- @change="handleChange">
- <a-select-option
- v-for="(label,value) in unitMap"
- :key="value"
- :label="label"
- :value="label">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <!-- <row-item>
- <a-form-item
- label="包装单位"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select
- show-search
- :value="unitNameBz"
- :default-active-first-option="false"
- :show-arrow="true"
- :filter-option="true"
- :not-found-content="null"
- @search="handleSearchBz"
- @blur="handleBlurBz"
- @change="handleChangeBz">
- <a-select-option
- v-for="(label,value) in unitMap"
- :key="value"
- :label="label"
- :value="label">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="折算系数"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- placeholder="单位折算为包装单位,如24个单位包装为一箱"
- v-decorator="['unitRate']" />
- </a-form-item>
- </row-item>-->
- <row-item>
- <a-form-item
- label="采购周期"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input suffix="天" v-decorator="['purchasePeriod']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="使用周期"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input suffix="月" v-decorator="['usePeriod']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="寿命周期"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input suffix="月" v-decorator="['agePeriod']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="最高库存"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input-number
- style="width: 100%"
- :min="1"
- v-decorator="['maxStock']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="最低库存"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input-number
- style="width: 100%"
- :min="1"
- v-decorator="['minStock']" />
- </a-form-item>
- </row-item>
- <row-item v-show="isAdd">
- <a-form-item
- label="初始库位"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-tree-select
- style="width: 100%"
- :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
- :treeData="storeTreeDate"
- :treeNodeFilterProp="'title'"
- :showSearch="true"
- v-decorator="['storeId', {rules: [{required: false, message: '仓库库位不能为空'}]}]"
- placeholder="请选择"
- >
- </a-tree-select>
- </a-form-item>
- </row-item>
- <row-item v-show="isAdd">
- <a-form-item
- label="初始库存"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input-number
- style="width: 100%"
- :min="1"
- v-decorator="['initStock']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="英文名称"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-input
- v-decorator="['englishName', {rules: [{required: false, message: '英文名称不能为空'}]}]" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="产地"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-select v-decorator="['cd']" placeholder="请选择">
- <a-select-option
- v-for="(label,value) in cdMap"
- :key="value"
- :label="label"
- :value="parseInt(value)">{{ label }}
- </a-select-option>
- </a-select>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="备件图片"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-upload
- :action="uploadUrl"
- :multiple="true"
- list-type="picture"
- :file-list="this.defaultApplicationFileList"
- @change="handleApplicationFileChange"
- accept="image/*"
- :headers="headers"
- >
- <a-button> <a-icon type="upload" /> 上传图片 </a-button>
- </a-upload>
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="参数"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-textarea
- v-decorator="['params']" />
- </a-form-item>
- </row-item>
- <row-item>
- <a-form-item
- label="备注"
- :labelCol="BaseTool.Constant.labelCol"
- :wrapperCol="BaseTool.Constant.wrapperCol"
- >
- <a-textarea
- v-decorator="['remark']" />
- </a-form-item>
- </row-item>
- </row-list>
- </a-form>
- <title-divider title="设备信息" width="100px"></title-divider>
- <div class="table-operator">
- <a-button style="margin-left:8px;" type="primary" @click="handleSbSelect">
- <a-icon type="plus"/>
- 添加
- </a-button>
- <a-button class="margin-left8" size="small" type="danger" @click="handleDel">
- <a-icon type="delete"/>
- 删除
- </a-button>
- </div>
- <a-table
- :data-source="data"
- :columns="columns"
- bordered
- tableLayout="auto"
- :row-selection="rowSelection"
- rowKey="id">
- <span slot="action" slot-scope="record">
- <template>
- <a v-if="$auth('sb-infos-edit')" @click="handleDetailSelect(record)">修改</a>
- <a-divider type="vertical" />
- <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="handleDelOne(record.id)">
- <a>删除</a>
- </a-popconfirm>
- </template>
- </span>
- </a-table>
- <p style="color: red">仓库数量初始化注意事项:<br/>
- 1:初始化库存仅能选择一个库位入库<br/>
- 2:初始化库存仅能新增,如需要修改请在仓库管理->仓库库存中修改数量<br/>
- </p>
- <template slot="footer">
- <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
- </template>
- <firm-producer-select-modal ref="producerSelectModal" @selected="handleProducerSelected"/>
- <supplier-select-modal ref="supplierSelectModal" @selected="handleSupplierSelected"/>
- <store-select-modal ref="storeSelectModal" @selected="handleStoreSelected"/>
- <sb-info-select-modal :type="'checkbox'" ref="sbInfoSelectModal" @selected="handleSbSelected"/>
- <base-form-spare ref="baseModal" @selected="handleDetailSelected"/>
- </a-card>
- </template>
- <script>
- import pick from 'lodash.pick'
- import { addSparePartInfo, querySparePartInfo, updateSparePartInfo } from '@/api/sqarepartmanage/sparepartinfo'
- import { querySpareType, fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
- import { fetchSbGuigeOptions } from '@/api/sb/guige'
- import FirmProducerSelectModal from '@/views/firm/producer/modules/FirmProducerSelectModal'
- import SupplierSelectModal from '@/views/purchase/supplier/modules/SupplierSelectModal'
- import UploadSpareFile from '@/components/Upload/UploadSpareFile'
- import Vue from 'vue'
- import StoreSelectModal from '@/views/store/store/modules/StoreSelectModal'
- import { uploadUrl } from '@/api/upms/file'
- import { ACCESS_TOKEN } from '@/store/mutation-types'
- import { fetchStoreTree } from '@/api/store/store'
- import { selectSbModelListBySpareId } from '@/api/sb/modelbom'
- import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
- import BaseFormSpare from '@/views/sb/modelbom/modules/BaseFormSpare'
- export default {
- name: 'BaseSparePartInfo',
- components: {
- FirmProducerSelectModal,
- SupplierSelectModal,
- UploadSpareFile,
- StoreSelectModal,
- SbInfoSelectModal,
- BaseFormSpare
- },
- data () {
- return {
- isAdd: false,
- unitName: null,
- unitNameBz: null,
- rowSelection: {
- onChange: (selectedRowKeys, selectedRows) => {
- this.selectedRowKeys = selectedRowKeys
- this.selectedRows = selectedRows
- }
- },
- gg: null,
- storeTreeDate: [],
- uploadUrl: uploadUrl,
- defaultApplicationFileList: [],
- applicationFileList: [], // 备件图片
- confirmLoading: false,
- modalTitle: null,
- form: this.$form.createForm(this),
- visible: false,
- // 下拉框map
- levelMap: {},
- periodTypeMap: {},
- unitMap: {},
- cdMap: {},
- ytMap: {},
- spareTypeData: [],
- spareTypeDataMiddle: [],
- spareTypeDataChild: [],
- producers: [],
- ggList: [],
- headers: {
- Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
- },
- // 表头
- columns: [
- {
- title: '型号',
- dataIndex: 'model'
- },
- {
- title: '名称',
- dataIndex: 'name'
- },
- {
- title: '新号',
- dataIndex: 'no'
- },
- {
- title: '旧号',
- dataIndex: 'zbh'
- },
- {
- title: '更换周期',
- dataIndex: 'period',
- customRender: (text, record, index) => {
- return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
- }
- },
- {
- title: '数量',
- dataIndex: 'num'
- },
- {
- title: '操作',
- key: 'action',
- checked: true,
- align: 'center',
- // fixed: 'right',
- scopedSlots: { customRender: 'action' }
- }
- ],
- data: [],
- sbId: null,
- selectedRowKeys: [],
- selectedRows: [],
- options: {
- rowSelection: {
- selectedRowKeys: this.selectedRowKeys
- }
- }
- }
- },
- props: {
- },
- created () {
- // 下拉框map
- this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
- this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
- this.cdMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PRODUCER_AREA)
- this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
- this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
- },
- methods: {
- base (record, sbId) {
- this.setTree(record)
- this.visible = true
- this.sbId = sbId
- console.log('sbId: ', sbId)
- // 如果是空标识添加
- if (this.BaseTool.Object.isBlank(record)) {
- this.modalTitle = '添加'
- this.isAdd = true
- return
- }
- this.modalTitle = '编辑'
- if (this.BaseTool.Object.isBlank(record.id)) {
- this.modalTitle = '复制'
- }
- selectSbModelListBySpareId({ id: record.id }).then(res => {
- this.data = res.data
- })
- const { form: { setFieldsValue } } = this
- this.applicationFileList = record.applicationFileList
- this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(this.applicationFileList)
- this.unitName = record.unit
- this.unitNameBz = record.unitBz
- this.gg = record.ggxh
- // 日期处理
- this.$nextTick(() => {
- setFieldsValue(Object.assign(pick(record, [
- 'id',
- 'no',
- 'sbId',
- 'initNo',
- 'uniteNo',
- 'nameNo',
- 'ggNo',
- 'name',
- 'parentTypeId',
- 'middleTypeId',
- 'childTypeId',
- 'typeId',
- 'level',
- 'initialValue',
- 'producerId',
- 'producerName',
- 'supplierId',
- 'supplierName',
- 'unit',
- 'unitBz',
- 'unitRate',
- 'englishName',
- 'childNo',
- 'parentNo',
- 'parentName',
- 'childName',
- 'typeName',
- 'middleNo',
- 'middleName',
- 'cd',
- 'ggxh',
- // 'yt',
- 'zjm',
- 'zbh',
- 'maxStock',
- 'minStock',
- 'initStock',
- 'remark'
- ])))
- })
- },
- save () {
- const { form: { validateFieldsAndScroll, setFieldsValue } } = this
- this.confirmLoading = true
- console.log('sbId: ' + this.sbId)
- setFieldsValue({
- 'unit': this.unitName,
- 'unitBz': this.unitNameBz,
- 'sbId': this.sbId
- })
- validateFieldsAndScroll((errors, values) => {
- if (errors) {
- this.confirmLoading = false
- return
- }
- values.applicationFileList = this.applicationFileList
- values.detailList = this.data
- // 日期处理
- if (this.BaseTool.String.isBlank(values.id)) {
- addSparePartInfo(values)
- .then(() => {
- this.handleCancel(values)
- }).catch(() => {
- this.confirmLoading = false
- })
- } else {
- updateSparePartInfo(values)
- .then(() => {
- this.handleCancel(values)
- }).catch(() => {
- this.confirmLoading = false
- })
- }
- })
- },
- handleProducerSelect () {
- this.$refs.producerSelectModal.base({}, { type: 3 })
- },
- handleProducerSelected (record, selectedRowKeys, selectedRow) {
- const { form: { setFieldsValue } } = this
- const [ key ] = selectedRowKeys
- const [ row ] = selectedRow
- setFieldsValue({
- 'producerId': key,
- 'producerName': row.name
- })
- },
- handleSupplierSelect () {
- this.$refs.supplierSelectModal.base()
- },
- handleSupplierSelected (record, selectedRowKeys, selectedRow) {
- const { form: { setFieldsValue } } = this
- const [ key ] = selectedRowKeys
- const [ row ] = selectedRow
- setFieldsValue({
- 'supplierId': key,
- 'supplierName': row.name
- })
- },
- handleCancel (values) {
- this.visible = false
- this.confirmLoading = false
- this.form.resetFields()
- this.unitName = null
- this.unitNameBz = null
- this.gg = null
- this.isAdd = true
- this.data = []
- if (this.BaseTool.Object.isNotBlank(values)) {
- this.$emit('ok', values)
- } else {
- this.$emit('ok')
- }
- },
- /**
- * 设置仓库、备件类别树
- */
- setTree (record = {}) {
- fetchStoreTree().then(res => {
- this.storeTreeDate = res.data
- })
- fetchSpareTypeTree().then(res => {
- this.spareTypeData = res.data
- })
- /* querySpareType({ filter: 2, parentId: record.parentTypeId }).then(res => {
- this.spareTypeDataMiddle = res.data
- })
- querySpareType({ filter: 2, parentId: record.middleTypeId }).then(res => {
- this.spareTypeDataChild = res.data
- }) */
- fetchSbGuigeOptions().then(res => {
- this.ggList = res.data
- })
- },
- checkSpareNo () {
- const { form: { getFieldValue } } = this
- const typeId = getFieldValue('typeId')
- const name = getFieldValue('name')
- // const ggxh = getFieldValue('ggxh')
- if (typeId == null) {
- this.$message.error('请先设置大小类型')
- return
- }
- querySparePartInfo({
- typeId: typeId,
- name: name,
- dataScope: {
- sortBy: 'desc',
- sortName: 'name'
- }
- }).then(res => {
- this.data = res.data
- })
- },
- /**
- * @function 任务类型文本框的值变化时的回调
- * @author ***
- * @time 2020-08-17
- **/
- handleSearch (value) {
- this.handleChange(value)
- },
- /**
- * @function 任务类型改变时的回调
- * @author ***
- * @time 2020-08-17
- **/
- handleChange (value) {
- this.unitName = (!isNaN(value) && value !== '') ? this.BaseTool.Object.getField(this.unitMap, value) : value
- if (isNaN(this.unitName) || this.unitName === '') {
- this.unitName = value
- }
- },
- /**
- * @function 修改设备关联
- * @author ***
- * @time 2020-08-17
- **/
- handleDetailSelect (record) {
- const modal = this.$refs.baseModal
- modal.base(record)
- },
- handleDetailSelected (values) {
- const newData = [...this.data]
- for (let j = 0; j < newData.length; j++) {
- if (values.sbId === newData[j].sbId) {
- newData[j].num = values.num
- newData[j].period = values.period
- newData[j].periodType = values.periodType
- break
- }
- }
- this.data = newData
- },
- /**
- * @function 添加关联设备
- * @author ***
- * @time 2020-08-17
- **/
- handleSbSelect () {
- const modal = this.$refs.sbInfoSelectModal
- modal.base()
- },
- handleSbSelected (keys, rows) {
- const { data } = this
- for (let i = 0; i < rows.length; i++) {
- var find = false
- for (let j = 0; j < data.length; j++) {
- if (rows[i].id === data[j].sbId) {
- find = true
- break
- }
- }
- if (!find) {
- const sbId = rows[i].id
- const selectData = rows[i]
- selectData.num = 1
- selectData.sbId = sbId
- selectData.id = null
- selectData.period = 1
- selectData.periodType = 1
- data.push(selectData)
- }
- }
- },
- /**
- * @function 任务类型失焦事件
- * @author ***
- * @time 2020-08-17
- **/
- handleBlur (value) {
- this.unitName = value
- },
- /**
- * @function 任务类型文本框的值变化时的回调
- * @author ***
- * @time 2020-08-17
- **/
- handleSearchBz (value) {
- this.handleChange(value)
- },
- /**
- * @function 任务类型改变时的回调
- * @author ***
- * @time 2020-08-17
- **/
- handleChangeBz (value) {
- this.unitNameBz = (!isNaN(value) && value !== '') ? this.BaseTool.Object.getField(this.unitMap, value) : value
- if (isNaN(this.unitNameBz) || this.unitNameBz === '') {
- this.unitNameBz = value
- }
- },
- /**
- * @function 任务类型失焦事件
- * @author ***
- * @time 2020-08-17
- **/
- handleBlurBz (value) {
- this.unitNameBz = value
- },
- /**
- * @function 任务类型文本框的值变化时的回调
- * @author ***
- * @time 2020-08-17
- **/
- handleSearchG (value) {
- this.handleChangeG(value)
- },
- /**
- * @function 任务类型改变时的回调
- * @author ***
- * @time 2020-08-17
- **/
- handleChangeG (value) {
- this.gg = (!isNaN(this.ggList[value]) && this.ggList[value] !== '') ? this.ggList[value].label : value
- if (isNaN(this.gg) || this.gg === '') {
- this.gg = value
- }
- },
- handleStoreSelect () {
- this.$refs.storeSelectModal.base()
- },
- handleStoreSelected (record, keys, rows) {
- const [ key ] = keys
- const [ row ] = rows
- const { form: { setFieldsValue } } = this
- // 日期处理
- this.$nextTick(() => {
- setFieldsValue(Object.assign({
- 'storeId': key,
- 'storeName': row.name
- }))
- })
- },
- handleDel (id) {
- const data = [...this.data]
- if (this.selectedRowKeys.length === 0) {
- this.$message.error('请至少选择一条数据')
- return
- }
- this.data = data.filter(item => !this.selectedRowKeys.includes(item.id))
- },
- handleDelOne (id) {
- const data = [...this.data]
- this.data = data.filter(item => id !== item.id)
- },
- /**
- * @function 任务类型失焦事件
- * @author ***
- * @time 2020-08-17
- **/
- handleBlurG (value) {
- this.gg = value
- },
- parentChange (val, option) {
- querySpareType({ parentId: val, filter: 2 }).then(res => {
- this.spareTypeDataMiddle = res.data
- })
- const { form: { setFieldsValue } } = this
- setFieldsValue({ parentNo: option.data.key, typeId: val, middleTypeId: null, middleNo: null, childTypeId: null, childNo: null })
- },
- middleChange (val, option) {
- querySpareType({ parentId: val, filter: 2 }).then(res => {
- this.spareTypeDataChild = res.data
- })
- const { form: { setFieldsValue } } = this
- setFieldsValue({ middleNo: option.data.key, typeId: val, childTypeId: null, childNo: null })
- },
- childChange (val, option) {
- const { form: { setFieldsValue } } = this
- setFieldsValue({ childNo: option.data.key, typeId: val, childTypeId: val })
- },
- handleApplicationFileChange (info) {
- this.defaultApplicationFileList = info.fileList
- this.applicationFileList = this.setFileList(info, 14)
- },
- setFileList (info, type) {
- const file = info.file
- const fileList = info.fileList
- if (file.status === 'done') {
- return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
- } else if (file.status === 'removed') {
- return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
- } else if (file.status === 'error') {
- this.$message.error('上传失败')
- return []
- }
- }
- }
- }
- </script>
|