SbInfo.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. <template>
  2. <div>
  3. <a-card :bordered="false" v-show="visible">
  4. <a-row :gutter="8" >
  5. <a-col :span="24">
  6. <div>
  7. <div class="table-page-search-wrapper">
  8. <a-form layout="inline">
  9. <a-row :gutter="48">
  10. <a-col :md="6" :sm="24">
  11. <a-form-item label="关键字">
  12. <a-input v-model.trim="queryParam.keyword" placeholder="设备编号"/>
  13. </a-form-item>
  14. </a-col>
  15. <a-col :md="6" :sm="24">
  16. <a-form-item label="车间位置">
  17. <a-select v-model="queryParam.positionId" placeholder="请选择">
  18. <a-select-option
  19. v-for="({id,name}) in sbPositionData"
  20. :key="id"
  21. :label="name"
  22. :value="id">{{ name }}
  23. </a-select-option>
  24. </a-select>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="设备名称">
  29. <a-input v-model.trim="queryParam.name" placeholder="名称"/>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="6" :sm="24">
  33. <a-form-item label="父位号">
  34. <a-input v-model.trim="queryParam.ppNo" placeholder="父位号"/>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="设备位号">
  39. <a-input v-model.trim="queryParam.positionNo" placeholder="设备位号"/>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-item label="生产商">
  44. <a-input v-model.trim="queryParam.producerId" placeholder="生产商"/>
  45. </a-form-item>
  46. </a-col>
  47. <!-- <a-col :md="6" :sm="24">
  48. <a-form-item label="设备自编号">
  49. <a-input v-model="queryParam.zbh" placeholder="设备自编号"/>
  50. </a-form-item>
  51. </a-col>-->
  52. <a-col :md="6" :sm="24">
  53. <a-form-item label="设备等级">
  54. <a-select v-model="queryParam.level" placeholder="请选择">
  55. <a-select-option
  56. v-for="(label,value) in levelMap"
  57. :key="value"
  58. :label="label"
  59. :value="parseInt(value)">{{ label }}
  60. </a-select-option>
  61. </a-select>
  62. </a-form-item>
  63. </a-col>
  64. <!-- <a-col :md="6" :sm="24">
  65. <a-form-item label="自定义类型">
  66. <a-select v-model="queryParam.useType" placeholder="请选择">
  67. <a-select-option
  68. v-for="(label,value) in useTypeMap"
  69. :key="value"
  70. :label="label"
  71. :value="parseInt(value)">{{ label }}
  72. </a-select-option>
  73. </a-select>
  74. </a-form-item>
  75. </a-col>-->
  76. <a-col :md="6" :sm="24">
  77. <a-form-item label="检定日期范围">
  78. <a-range-picker v-model="dateRangeCheck" />
  79. </a-form-item>
  80. </a-col>
  81. <a-col :md="6" :sm="24">
  82. <a-form-item label="有效日期范围">
  83. <a-range-picker v-model="dateRange"/>
  84. </a-form-item>
  85. </a-col>
  86. <a-col :md="6" :sm="24">
  87. <a-form-item label="规格型号">
  88. <a-input v-model="queryParam.model" placeholder="规格型号"/>
  89. </a-form-item>
  90. </a-col>
  91. <a-col :md="6" :sm="24">
  92. <a-form-item label="设备类型">
  93. <a-tree-select
  94. style="width: 100%"
  95. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  96. :treeData="treeData"
  97. :treeNodeFilterProp="'title'"
  98. :showSearch="true"
  99. placeholder="请选择"
  100. @change="handleChange"
  101. >
  102. </a-tree-select>
  103. </a-form-item>
  104. </a-col>
  105. <a-col :md="6" :sm="24">
  106. <a-form-item label="设备状态">
  107. <a-select v-model="queryParam.status" placeholder="请选择">
  108. <a-select-option
  109. v-for="(label,value) in statusMap"
  110. :key="value"
  111. :defaultValue="DictCache.VALUE.SB_INFO_STATUS.IN_USE"
  112. :label="label"
  113. :value="parseInt(value)">{{ label }}
  114. </a-select-option>
  115. </a-select>
  116. </a-form-item>
  117. </a-col>
  118. <a-col :md="6" :sm="24">
  119. <a-form-item label="主子设备">
  120. <a-select v-model="queryParam.isChild" placeholder="请选择">
  121. <a-select-option value="1">子设备</a-select-option>
  122. <a-select-option value="2">父设备</a-select-option>
  123. <a-select-option value="3">普通设备</a-select-option>
  124. </a-select>
  125. </a-form-item>
  126. </a-col>
  127. <a-col :md="6" :sm="24">
  128. <a-form-item label="电力线路">
  129. <a-select v-model="queryParam.baoyangTimes" placeholder="请选择">
  130. <a-select-option
  131. v-for="(label,value) in lineMap"
  132. :key="value"
  133. :label="label"
  134. :value="parseInt(value)">{{ label }}
  135. </a-select-option>
  136. </a-select>
  137. </a-form-item>
  138. </a-col>
  139. <a-col :md="6 || 24" :sm="24">
  140. <span class="table-page-search-submitButtons">
  141. <a-button type="primary" @click="handleOk">查询</a-button>
  142. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  143. </span>
  144. </a-col>
  145. </a-row>
  146. </a-form>
  147. </div>
  148. <div class="table-operator" style="margin-bottom: 8px;">
  149. <a-button v-if="$auth('sb-infos-add')" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  150. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  151. <!-- <a-button style="margin-left:8px;" type="primary" @click="doImport">
  152. <a-icon type="upload"/>
  153. 新增导入
  154. </a-button>-->
  155. <a-button style="margin-left:8px;" type="primary" @click="doImportStandard">
  156. <a-icon type="upload"/>
  157. 导入
  158. </a-button>
  159. <a-button style="margin-left:8px;" type="primary" @click="doImportForUpdate">
  160. <a-icon type="upload"/>
  161. 修改导入
  162. </a-button>
  163. <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrintBatch()">批量打印</a-button>
  164. <!-- <a-button style="margin-left: 8px" type="primary" icon="reload" @click="handleMeasureBatch()">批量检定</a-button> -->
  165. <a-button style="margin-left: 8px" v-if="$auth('sb-infos-generate-code-all')" :loading="confirmLoading" type="primary" @click="batchGenerate()">重新生成二维码</a-button>
  166. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
  167. <a-menu slot="overlay">
  168. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  169. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  170. </a-popconfirm>
  171. <a-popconfirm v-if="isMeasure===1" @visibleChange="batchIncorrect()">
  172. <a-menu-item key="2"><my-icon type="icon-pandian" /><a>检定</a></a-menu-item>
  173. </a-popconfirm>
  174. <a-popconfirm v-if="isMeasure===1" @visibleChange="batchIncorrectInStore()">
  175. <a-menu-item key="3"><my-icon type="icon-pandian" /><a>入库</a></a-menu-item>
  176. </a-popconfirm>
  177. <a-popconfirm :visible="false" @visibleChange="batchLocation()">
  178. <a-menu-item key="4"><my-icon type="icon-pandian" /><a>设备位号</a></a-menu-item>
  179. </a-popconfirm>
  180. </a-menu>
  181. <a-button style="margin-left: 8px">
  182. 批量操作 <a-icon type="down" />
  183. </a-button>
  184. </a-dropdown>
  185. </div>
  186. <s-table
  187. ref="table"
  188. @expand="onExpand"
  189. size="default"
  190. rowKey="id"
  191. :widthSpace="true"
  192. :columns="columns"
  193. :data="loadData"
  194. :alert="options.alert"
  195. :rowSelection="options.rowSelection"
  196. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  197. showPagination="auto"
  198. >
  199. <template #positionNo="text,record">
  200. <a @click="showChangeLog(record)">{{ text }}</a>
  201. </template>
  202. <span slot="action" slot-scope="record">
  203. <template>
  204. <div>
  205. <!--<a-divider type="vertical" />
  206. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该设备?" @confirm="batchDelete(record.id)">
  207. <a>删除</a>
  208. </a-popconfirm>
  209. <a-divider type="vertical" />
  210. <a @click="handleCopy(record)">复制</a>-->
  211. <a-dropdown>
  212. <a-menu slot="overlay">
  213. <a-menu-item key="0">
  214. <a @click="handleView(record)">查看</a>
  215. </a-menu-item>
  216. <a-menu-item key="1">
  217. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  218. </a-menu-item>
  219. <a-menu-item key="2" v-if="isMeasure===1" >
  220. <a @click="batchIncorrect(record)">检定</a>
  221. </a-menu-item>
  222. <a-menu-item key="3" v-if="isMeasure===1" >
  223. <a @click="batchIncorrectInStore(record)">入库</a>
  224. </a-menu-item>
  225. <a-menu-item v-if="record.status != 2" key="2">
  226. <a-popconfirm title="是否要启用该设备?" @confirm="handleStart(record)">
  227. <a>启用</a>
  228. </a-popconfirm>
  229. </a-menu-item>
  230. <a-menu-item v-if="record.status != 7" key="3">
  231. <a-popconfirm title="是否要停用该设备?" @confirm="handleStop(record)">
  232. <a>停用</a>
  233. </a-popconfirm>
  234. </a-menu-item>
  235. <a-menu-item key="10">
  236. <a v-if="$auth('sb-infos-edit')" @click="handleCopy(record)">复制</a>
  237. </a-menu-item>
  238. <a-menu-item key="4">
  239. <a @click="handlePrint(record)">打印</a>
  240. </a-menu-item>
  241. </a-menu>
  242. <a-button> 操作 <a-icon type="down" /> </a-button>
  243. </a-dropdown>
  244. </div>
  245. </template>
  246. </span>
  247. <span slot="status" slot-scope="text">
  248. <badge
  249. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  250. :text="statusMap[text]" />
  251. </span>
  252. <span slot="measureStatus" slot-scope="text">
  253. <badge
  254. :status="DictCache.COLOR.SB_MEASURE_STATUS[text]"
  255. :text="yesNoMap[text]" />
  256. </span>
  257. </s-table>
  258. </div>
  259. </a-col>
  260. </a-row>
  261. </a-card>
  262. <base-form ref="baseModal" :parent-id="queryParam.parentId" :parent-name="queryParam.parentName" @ok="handleOk"/>
  263. <base-form-status-log ref="baseModalStatusLog" @ok="handleOk"/>
  264. <detail ref="detailModal" @ok="handleOk"/>
  265. <download-modal ref="downloadModal"/>
  266. <preview-modal ref="previewModal"/>
  267. <import-form-add ref="importModal" @ok="handleOk"/>
  268. <import-form-add-standard ref="importModalStandard" @ok="handleOk"/>
  269. <import-form-update ref="importModalUpdate" @ok="handleOk"/>
  270. <print-sb-code ref="printSbCode"/>
  271. <print-in-sb-info-batch ref="printInSbInfoBatch" @ok="handleOk"/>
  272. <detail-sb-measure ref="detailSbMeasureModal" @ok="handleOk"/>
  273. <base-form-measure ref="baseModalMeasure" @ok="handleOk"/>
  274. <base-form-measure-in-store ref="baseModalMeasureInStore" @ok="handleOk"/>
  275. <base-form-location ref="baseFormLocation" @ok="handleOk" />
  276. <SbChangeLogSelectModal ref="sbChangeRecordSelectModal" @ok="handleOk" />
  277. </div>
  278. </template>
  279. <script>
  280. import { STable, Ellipsis } from '@/components'
  281. import BaseForm from './modules/BaseForm'
  282. import DetailSbMeasure from '@/views/sb/measurelog/modules/DetailSbCheckBatch'
  283. import BaseFormStatusLog from '@/views/sb/status-log/modules/BaseForm'
  284. import Detail from './modules/Detail'
  285. import BaseFormMeasure from './modules/BaseFormMeasure'
  286. import BaseFormMeasureInStore from './modules/BaseFormMeasureInStore'
  287. import BaseFormLocation from './modules/BaseFormLocation'
  288. import DownloadModal from '@/views/download/DownloadModal'
  289. import PreviewModal from '@/views/preview/PreviewModal'
  290. import { getSbInfoPage, deleteSbInfos, querySbInfo, fetchSbInfo, fetchSbInfos, exportSbInfo, batchLocationList } from '@/api/sb/info'
  291. import { queryDept } from '@/api/upms/dept'
  292. import { generateSbCodeAll } from '@/api/upms/code'
  293. import { fetchSbTypeTree } from '@/api/sb/type'
  294. import ImportFormAdd from './modules/ImportFormAdd'
  295. import ImportFormAddStandard from './modules/ImportFormAddStandard'
  296. import ImportFormUpdate from './modules/ImportFormUpdate'
  297. import PrintSbCode from '@/views/sb/info/modules/PrintSbCode'
  298. import PrintInSbInfoBatch from '@/views/sb/info/modules/PrintInSbInfoBatch'
  299. import { querySbPosition } from '@/api/sb/position'
  300. import SbChangeLogSelectModal from '@/views/sb/change-log/modules/SbChangeLogSelectModal'
  301. export default {
  302. name: 'SbInfoList',
  303. components: {
  304. STable,
  305. Ellipsis,
  306. BaseForm,
  307. DetailSbMeasure,
  308. Detail,
  309. DownloadModal,
  310. PreviewModal,
  311. PrintSbCode,
  312. ImportFormAdd,
  313. ImportFormAddStandard,
  314. ImportFormUpdate,
  315. PrintInSbInfoBatch,
  316. BaseFormMeasure,
  317. BaseFormMeasureInStore,
  318. BaseFormLocation,
  319. BaseFormStatusLog,
  320. SbChangeLogSelectModal
  321. },
  322. props: {
  323. filter: {
  324. type: Number,
  325. default: -1
  326. },
  327. useType: {
  328. type: Number,
  329. default: null
  330. },
  331. correctType: {
  332. type: Number,
  333. default: 1
  334. },
  335. measureStatus: {
  336. type: Number,
  337. default: null
  338. },
  339. isMeasure: {
  340. type: Number,
  341. default: null
  342. },
  343. isSelf: {
  344. type: Number,
  345. default: null
  346. },
  347. status: {
  348. type: Number,
  349. default: null
  350. }
  351. },
  352. data () {
  353. return {
  354. // 查询参数
  355. queryParam: {
  356. filter: this.filter,
  357. useType: this.useType,
  358. measureStatus: this.measureStatus,
  359. isMeasure: this.isMeasure,
  360. isSelf: this.isSelf,
  361. id: this.$route.query.id,
  362. typeId: this.$route.query.typeId,
  363. status: this.$route.query.status || this.status
  364. },
  365. depreciationTypeMap: {},
  366. visible: true,
  367. dateRange: [],
  368. dateRangeCheck: [],
  369. sbPositionData: [],
  370. levelMap: {},
  371. lineMap: {},
  372. unitMap: {},
  373. areaList: {},
  374. companyList: {},
  375. projectList: {},
  376. isChildMap: {},
  377. isShowMap: {},
  378. deptList: {},
  379. confirmLoading: false,
  380. useTypeMap: {},
  381. statusMap: {},
  382. yesNoMap: {},
  383. expandedKeys: [],
  384. selectedKeys: [],
  385. sourceTypeMap: {},
  386. treeData: [],
  387. typeList: [],
  388. // 表头
  389. columns: [
  390. /* {
  391. title: '序号',
  392. dataIndex: 'index',
  393. width: 100,
  394. checked: true,
  395. customRender: (text, record, index) => {
  396. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  397. }
  398. }, */
  399. {
  400. title: '设备位置',
  401. checked: true,
  402. width: 200,
  403. dataIndex: 'positionName'
  404. },
  405. {
  406. title: '设备名称',
  407. checked: true,
  408. width: 200,
  409. dataIndex: 'name'
  410. },
  411. {
  412. title: '设备位号',
  413. dataIndex: 'positionNo',
  414. width: 150,
  415. scopedSlots: { customRender: 'positionNo' },
  416. checked: true
  417. },
  418. {
  419. title: '父位号',
  420. dataIndex: 'ppNo',
  421. width: 120,
  422. checked: true
  423. },
  424. {
  425. title: '设备类型',
  426. checked: true,
  427. dataIndex: 'type',
  428. width: 150,
  429. customRender: (text, record, index) => {
  430. return record.typeName
  431. }
  432. },
  433. /* {
  434. title: '设备等级',
  435. checked: true,
  436. dataIndex: 'level',
  437. width: 120,
  438. customRender: (text, record, index) => {
  439. return this.BaseTool.Object.getField(this.levelMap, text)
  440. }
  441. }, */
  442. {
  443. title: '规格型号',
  444. dataIndex: 'model',
  445. width: 150,
  446. checked: true
  447. },
  448. {
  449. title: '设备编号',
  450. dataIndex: 'no',
  451. width: 150,
  452. checked: true
  453. },
  454. {
  455. title: '巡检序号',
  456. dataIndex: 'sortNum',
  457. width: 120,
  458. checked: true
  459. },
  460. /* {
  461. title: '自定义类型',
  462. checked: true,
  463. dataIndex: 'useType',
  464. width: 150,
  465. customRender: (text, record, index) => {
  466. return this.BaseTool.Object.getField(this.useTypeMap, text)
  467. }
  468. }, */
  469. /* {
  470. title: '使用机台',
  471. checked: true,
  472. width: 200,
  473. dataIndex: 'saveUserName'
  474. },
  475. {
  476. title: '生产商',
  477. dataIndex: 'producerId',
  478. width: 120,
  479. checked: true
  480. }, */
  481. /* {
  482. title: '大小尺寸',
  483. dataIndex: 'zz',
  484. width: 120,
  485. checked: true
  486. }, */
  487. {
  488. title: '出厂编号',
  489. dataIndex: 'zzh',
  490. width: 120,
  491. checked: true
  492. },
  493. {
  494. title: '设备识别码',
  495. dataIndex: 'identifyNo',
  496. width: 120,
  497. checked: true
  498. },
  499. {
  500. title: '使用证号',
  501. dataIndex: 'useNo',
  502. width: 120,
  503. checked: true
  504. },
  505. {
  506. title: '设备代号',
  507. dataIndex: 'sbCode',
  508. width: 120,
  509. checked: true
  510. },
  511. {
  512. title: '安装单位',
  513. dataIndex: 'installUnit',
  514. width: 120,
  515. checked: true
  516. },
  517. {
  518. title: '检验结论',
  519. dataIndex: 'examResult',
  520. width: 120,
  521. checked: true
  522. },
  523. {
  524. title: '单位内部使用地点',
  525. dataIndex: 'usePosition',
  526. width: 120,
  527. checked: true
  528. },
  529. /* {
  530. title: '是否显示',
  531. dataIndex: 'isShow',
  532. width: 120,
  533. checked: true,
  534. customRender: (text, record, index) => {
  535. return this.BaseTool.Object.getField(this.isShowMap, text)
  536. }
  537. }, */
  538. /* {
  539. title: '是否子设备',
  540. dataIndex: 'isChild',
  541. width: 120,
  542. checked: true,
  543. customRender: (text, record, index) => {
  544. return this.BaseTool.Object.getField(this.isChildMap, text)
  545. }
  546. }, */
  547. /* {
  548. title: '资产编号',
  549. dataIndex: 'financingNo',
  550. width: 120,
  551. checked: true
  552. },
  553. {
  554. title: '设备原值',
  555. dataIndex: 'initialValue',
  556. width: 100,
  557. checked: true,
  558. customRender: (text, record, index) => {
  559. return this.BaseTool.Amount.formatter(text)
  560. }
  561. },
  562. {
  563. title: '购置日期',
  564. dataIndex: 'buyDate',
  565. width: 120,
  566. checked: true
  567. },
  568. {
  569. title: '投用日期',
  570. dataIndex: 'startDate',
  571. width: 120,
  572. checked: true
  573. }, */
  574. /* {
  575. title: '检定日期',
  576. dataIndex: 'checkDate',
  577. width: 150,
  578. checked: true
  579. },
  580. {
  581. title: '检定周期',
  582. dataIndex: 'checkPeriod',
  583. width: 100,
  584. checked: true,
  585. customRender: (text, record, index) => {
  586. if (record.nextCheckDate == null) {
  587. return '未知'
  588. } else {
  589. return text + '月'
  590. }
  591. }
  592. }, */
  593. {
  594. title: '检定有效期',
  595. dataIndex: 'nextCheckDate',
  596. fixed: 'right',
  597. width: 150,
  598. checked: true
  599. },
  600. /* {
  601. title: '检定截止',
  602. dataIndex: 'restDay',
  603. width: 100,
  604. checked: true,
  605. customRender: (text, record, index) => {
  606. if (record.nextCheckDate == null) {
  607. return '未知'
  608. } else {
  609. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  610. }
  611. }
  612. }, */
  613. {
  614. title: '状态',
  615. checked: true,
  616. dataIndex: 'status',
  617. fixed: 'right',
  618. width: 100,
  619. scopedSlots: { customRender: 'status' }
  620. },
  621. {
  622. title: '检定状态',
  623. checked: true,
  624. dataIndex: 'measureStatus',
  625. fixed: 'right',
  626. width: 100,
  627. scopedSlots: { customRender: 'measureStatus' }
  628. },
  629. {
  630. title: '操作',
  631. key: 'action',
  632. checked: true,
  633. fixed: 'right',
  634. align: 'center',
  635. width: '120',
  636. scopedSlots: { customRender: 'action' }
  637. }
  638. ],
  639. // 加载数据方法 必须为 Promise 对象
  640. loadData: parameter => {
  641. parameter = {
  642. ...parameter,
  643. ...this.queryParam,
  644. typeList: this.typeList,
  645. dataScope: {
  646. sortBy: 'asc',
  647. sortName: 'no'
  648. }
  649. }
  650. this.selectedRowKeys = []
  651. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  652. .then(res => {
  653. return res.data
  654. })
  655. },
  656. selectedRowKeys: [],
  657. selectedRows: [],
  658. options: {
  659. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  660. rowSelection: {
  661. selectedRowKeys: this.selectedRowKeys,
  662. onChange: this.onSelectChange
  663. }
  664. },
  665. optionAlertShow: false
  666. }
  667. },
  668. created () {
  669. console.log('this.$route.query.parentId: ' + this.$route.query.parentId)
  670. this.queryParam.parentId = this.$route.query.parentId
  671. this.queryParam.parentName = this.$route.query.parentName
  672. this.tableOption()
  673. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  674. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  675. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  676. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  677. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  678. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  679. this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
  680. this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
  681. this.lineMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_LINE)
  682. this.yesNoMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  683. querySbPosition().then(res => {
  684. this.sbPositionData = res.data
  685. })
  686. },
  687. methods: {
  688. tableOption () {
  689. this.setTree()
  690. if (!this.optionAlertShow) {
  691. this.options = {
  692. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  693. rowSelection: {
  694. selectedRowKeys: this.selectedRowKeys,
  695. onChange: this.onSelectChange,
  696. getCheckboxProps: record => ({
  697. props: {
  698. disabled: false,
  699. name: record.id
  700. }
  701. })
  702. }
  703. }
  704. this.optionAlertShow = true
  705. } else {
  706. this.options = {
  707. alert: false,
  708. rowSelection: null
  709. }
  710. this.optionAlertShow = false
  711. }
  712. },
  713. batchDelete (id) {
  714. let ids = []
  715. if (this.BaseTool.String.isBlank(id)) {
  716. const length = this.selectedRows.length
  717. if (length === 0) {
  718. this.$message.info('请选择要删除的记录')
  719. return
  720. }
  721. ids = this.selectedRows.map(item => item.id)
  722. } else {
  723. ids = [id]
  724. }
  725. deleteSbInfos(ids).then(res => {
  726. this.$message.info('删除成功')
  727. this.handleOk()
  728. this.$refs.table.clearSelected()
  729. })
  730. },
  731. batchGenerate () {
  732. this.confirmLoading = true
  733. this.$message.info('正在生成请稍后')
  734. generateSbCodeAll().then(res => {
  735. this.confirmLoading = false
  736. this.$message.info('生成成功')
  737. this.handleOk()
  738. this.$refs.table.clearSelected()
  739. })
  740. },
  741. handleEdit (record) {
  742. fetchSbInfo({ id: record.id }).then(res => {
  743. this.visible = false
  744. const modal = this.$refs.baseModal
  745. modal.base(res.data)
  746. })
  747. },
  748. handlePrint (record) {
  749. this.visible = false
  750. fetchSbInfo({ id: record.id }).then(res => {
  751. const modal = this.$refs.printInSbInfoBatch
  752. modal.base([res.data])
  753. })
  754. },
  755. batchLocation () {
  756. let ids = []
  757. const length = this.selectedRows.length
  758. if (length === 0) {
  759. this.$message.info('请选择设备')
  760. return
  761. }
  762. ids = this.selectedRows.map(item => item.id)
  763. console.log(ids)
  764. batchLocationList({ ids }).then(res => {
  765. this.visible = false
  766. const modal = this.$refs.baseFormLocation
  767. modal.base(res.data)
  768. })
  769. },
  770. batchIncorrect (id) {
  771. let ids = []
  772. if (this.BaseTool.String.isBlank(id)) {
  773. const length = this.selectedRows.length
  774. if (length === 0) {
  775. this.$message.info('请选择要填报的设备')
  776. return
  777. }
  778. ids = this.selectedRows
  779. } else {
  780. ids = [id]
  781. }
  782. this.visible = false
  783. const modal = this.$refs.baseModalMeasure
  784. modal.base(ids, this.correctType)
  785. },
  786. batchIncorrectInStore (id) {
  787. let ids = []
  788. if (this.BaseTool.String.isBlank(id)) {
  789. const length = this.selectedRows.length
  790. if (length === 0) {
  791. this.$message.info('请选择要填报的设备')
  792. return
  793. }
  794. ids = this.selectedRows
  795. } else {
  796. ids = [id]
  797. }
  798. this.visible = false
  799. const modal = this.$refs.baseModalMeasureInStore
  800. modal.base(ids, this.correctType)
  801. },
  802. handleMeasureBatch () {
  803. const modal = this.$refs.detailSbMeasureModal
  804. modal.base()
  805. },
  806. handlePrintBatch () {
  807. this.visible = false
  808. let ids = []
  809. const length = this.selectedRows.length
  810. if (length === 0) {
  811. this.$message.info('请选择要打印的设备')
  812. return
  813. }
  814. ids = this.selectedRows.map(item => item.id)
  815. fetchSbInfos(ids).then(res => {
  816. const modal = this.$refs.printInSbInfoBatch
  817. modal.base(res.data)
  818. })
  819. },
  820. handleStart (record) {
  821. const modal = this.$refs.baseModalStatusLog
  822. modal.base(null, {
  823. sbId: record.id,
  824. sbNo: record.no,
  825. changeUserId: this.$store.getters.userInfo.userId,
  826. actualUser: this.$store.getters.userInfo.realName,
  827. preStatus: record.status,
  828. afterStatus: this.DictCache.VALUE.SB_INFO_STATUS.IN_USE
  829. })
  830. },
  831. handleStop (record) {
  832. const modal = this.$refs.baseModalStatusLog
  833. modal.base(null, {
  834. sbId: record.id,
  835. sbNo: record.no,
  836. changeUserId: this.$store.getters.userInfo.userId,
  837. actualUser: this.$store.getters.userInfo.realName,
  838. preStatus: record.status,
  839. afterStatus: this.DictCache.VALUE.SB_INFO_STATUS.IN_STOP
  840. })
  841. },
  842. handleAdd () {
  843. this.visible = false
  844. this.$refs.baseModal.base()
  845. },
  846. handleView (record) {
  847. fetchSbInfo({ id: record.id }).then(res => {
  848. this.visible = false
  849. const modal = this.$refs.detailModal
  850. modal.base(res.data)
  851. })
  852. },
  853. showChangeLog (record) {
  854. console.log(record)
  855. console.log(this.$refs)
  856. this.$refs.sbChangeRecordSelectModal.base({}, { sbId: record.id })
  857. },
  858. handleCopy (record) {
  859. this.visible = false
  860. fetchSbInfo({ id: record.id }).then(res => {
  861. const modal = this.$refs.baseModal
  862. modal.base(res.data, 1)
  863. })
  864. },
  865. handleOk () {
  866. this.visible = true
  867. this.setTree()
  868. if (this.dateRange != null) {
  869. this.queryParam.nextCheckDateStart = this.dateRange[0]
  870. this.queryParam.nextCheckDateEnd = this.dateRange[1]
  871. this.queryParam.nextCheckDateStart = this.queryParam.nextCheckDateStart ? this.queryParam.nextCheckDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  872. this.queryParam.nextCheckDateEnd = this.queryParam.nextCheckDateEnd ? this.queryParam.nextCheckDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  873. }
  874. if (this.dateRangeCheck != null) {
  875. this.queryParam.checkDateStart = this.dateRangeCheck[0]
  876. this.queryParam.checkDateEnd = this.dateRangeCheck[1]
  877. this.queryParam.checkDateStart = this.queryParam.checkDateStart ? this.queryParam.checkDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  878. this.queryParam.checkDateEnd = this.queryParam.checkDateEnd ? this.queryParam.checkDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  879. }
  880. this.$refs.table.refresh()
  881. },
  882. onSelectChange (selectedRowKeys, selectedRows) {
  883. this.selectedRowKeys = selectedRowKeys
  884. this.selectedRows = selectedRows
  885. },
  886. resetSearchForm () {
  887. this.queryParam = {
  888. filter: this.filter,
  889. useType: this.useType,
  890. measureStatus: this.measureStatus,
  891. isMeasure: this.isMeasure,
  892. isSelf: this.isSelf,
  893. id: this.$route.query.id,
  894. typeId: this.$route.query.typeId,
  895. status: this.$route.query.status || this.status
  896. }
  897. this.visible = true
  898. this.$refs.table.refresh(true)
  899. },
  900. doExport () {
  901. const parameter = {
  902. ...this.queryParam,
  903. sbIds: this.selectedRowKeys,
  904. dataScope: {
  905. sortBy: 'asc',
  906. sortName: 'no'
  907. }
  908. }
  909. exportSbInfo(parameter).then(file => {
  910. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  911. })
  912. },
  913. setTree (record = {}) {
  914. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  915. this.areaList = res.data
  916. })
  917. fetchSbTypeTree().then(res => {
  918. this.treeData = res.data
  919. })
  920. },
  921. onSelect: function (selectedKeys, info) {
  922. this.selectedKeys = selectedKeys
  923. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  924. this.$refs.table.refresh(true)
  925. },
  926. onExpand (expanded, record) { // expanded判断展开or收缩操作,record当前行数据
  927. console.log(expanded)
  928. if (expanded) {
  929. querySbInfo({ positionNo: record.positionNo }).then(res => {
  930. record.children = res.data
  931. })
  932. }
  933. },
  934. doImport () {
  935. this.$refs.importModal.base(null, null)
  936. },
  937. doImportStandard () {
  938. // this.$refs.importModalStandard.base()
  939. this.$refs.importModalUpdate.base(null, 1)
  940. },
  941. doImportForUpdate () {
  942. this.$refs.importModalUpdate.base(null, 2)
  943. },
  944. handleChange (value, label, extra) {
  945. alert(value)
  946. const data = this.treeData.find(item => item.id === value)
  947. if (data && data.children && data.children.length > 0) {
  948. this.typeList = data.children.map(item => item.id)
  949. } else {
  950. this.typeList = [value]
  951. }
  952. }
  953. }
  954. }
  955. </script>