SbInfo.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  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. v-model="queryParam.typeId"
  100. placeholder="请选择"
  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 || correctType===2" :visible="false" @visibleChange="batchIncorrect()">
  172. <a-menu-item key="2"><my-icon type="icon-pandian" /><a>检定</a></a-menu-item>
  173. </a-popconfirm>
  174. <a-popconfirm :visible="false" @visibleChange="batchLocation()">
  175. <a-menu-item key="3"><my-icon type="icon-pandian" /><a>设备位号</a></a-menu-item>
  176. </a-popconfirm>
  177. </a-menu>
  178. <a-button style="margin-left: 8px">
  179. 批量操作 <a-icon type="down" />
  180. </a-button>
  181. </a-dropdown>
  182. </div>
  183. <s-table
  184. ref="table"
  185. @expand="onExpand"
  186. size="default"
  187. rowKey="id"
  188. :widthSpace="true"
  189. :columns="columns"
  190. :data="loadData"
  191. :alert="options.alert"
  192. :rowSelection="options.rowSelection"
  193. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  194. showPagination="auto"
  195. >
  196. <span slot="action" slot-scope="record">
  197. <template>
  198. <div>
  199. <!--<a-divider type="vertical" />
  200. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该设备?" @confirm="batchDelete(record.id)">
  201. <a>删除</a>
  202. </a-popconfirm>
  203. <a-divider type="vertical" />
  204. <a @click="handleCopy(record)">复制</a>-->
  205. <a-dropdown>
  206. <a-menu slot="overlay">
  207. <a-menu-item key="0">
  208. <a @click="handleView(record)">查看</a>
  209. </a-menu-item>
  210. <a-menu-item key="1">
  211. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  212. </a-menu-item>
  213. <a-menu-item key="2" v-if="isMeasure===1 || correctType===2" >
  214. <a @click="batchIncorrect(record)">检定</a>
  215. </a-menu-item>
  216. <a-menu-item v-if="record.status != 2" key="2">
  217. <a-popconfirm title="是否要启用该设备?" @confirm="handleStart(record)">
  218. <a>启用</a>
  219. </a-popconfirm>
  220. </a-menu-item>
  221. <a-menu-item v-if="record.status != 7" key="3">
  222. <a-popconfirm title="是否要停用该设备?" @confirm="handleStop(record)">
  223. <a>停用</a>
  224. </a-popconfirm>
  225. </a-menu-item>
  226. <a-menu-item key="10">
  227. <a v-if="$auth('sb-infos-edit')" @click="handleCopy(record)">复制</a>
  228. </a-menu-item>
  229. <a-menu-item key="4">
  230. <a @click="handlePrint(record)">打印</a>
  231. </a-menu-item>
  232. </a-menu>
  233. <a-button> 操作 <a-icon type="down" /> </a-button>
  234. </a-dropdown>
  235. </div>
  236. </template>
  237. </span>
  238. <span slot="status" slot-scope="text">
  239. <badge
  240. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  241. :text="statusMap[text]" />
  242. </span>
  243. </s-table>
  244. </div>
  245. </a-col>
  246. </a-row>
  247. </a-card>
  248. <base-form ref="baseModal" :parent-id="queryParam.parentId" :parent-name="queryParam.parentName" @ok="handleOk"/>
  249. <base-form-status-log ref="baseModalStatusLog" @ok="handleOk"/>
  250. <detail ref="detailModal" @ok="handleOk"/>
  251. <download-modal ref="downloadModal"/>
  252. <preview-modal ref="previewModal"/>
  253. <import-form-add ref="importModal" @ok="handleOk"/>
  254. <import-form-add-standard ref="importModalStandard" @ok="handleOk"/>
  255. <import-form-update ref="importModalUpdate" @ok="handleOk"/>
  256. <print-sb-code ref="printSbCode"/>
  257. <print-in-sb-info-batch ref="printInSbInfoBatch" @ok="handleOk"/>
  258. <detail-sb-measure ref="detailSbMeasureModal" @ok="handleOk"/>
  259. <base-form-measure ref="baseModalMeasure" @ok="handleOk"/>
  260. <base-form-location ref="baseFormLocation" @ok="handleOk" />
  261. </div>
  262. </template>
  263. <script>
  264. import { STable, Ellipsis } from '@/components'
  265. import BaseForm from './modules/BaseForm'
  266. import DetailSbMeasure from '@/views/sb/measurelog/modules/DetailSbCheckBatch'
  267. import BaseFormStatusLog from '@/views/sb/status-log/modules/BaseForm'
  268. import Detail from './modules/Detail'
  269. import BaseFormMeasure from './modules/BaseFormMeasure'
  270. import BaseFormLocation from './modules/BaseFormLocation'
  271. import DownloadModal from '@/views/download/DownloadModal'
  272. import PreviewModal from '@/views/preview/PreviewModal'
  273. import { getSbInfoPage, deleteSbInfos, querySbInfo, fetchSbInfo, fetchSbInfos, exportSbInfo, batchLocationList } from '@/api/sb/info'
  274. import { queryDept } from '@/api/upms/dept'
  275. import { generateSbCodeAll } from '@/api/upms/code'
  276. import { fetchSbTypeTree } from '@/api/sb/type'
  277. import ImportFormAdd from './modules/ImportFormAdd'
  278. import ImportFormAddStandard from './modules/ImportFormAddStandard'
  279. import ImportFormUpdate from './modules/ImportFormUpdate'
  280. import PrintSbCode from '@/views/sb/info/modules/PrintSbCode'
  281. import PrintInSbInfoBatch from '@/views/sb/info/modules/PrintInSbInfoBatch'
  282. import { querySbPosition } from '@/api/sb/position'
  283. export default {
  284. name: 'SbInfoList',
  285. components: {
  286. STable,
  287. Ellipsis,
  288. BaseForm,
  289. DetailSbMeasure,
  290. Detail,
  291. DownloadModal,
  292. PreviewModal,
  293. PrintSbCode,
  294. ImportFormAdd,
  295. ImportFormAddStandard,
  296. ImportFormUpdate,
  297. PrintInSbInfoBatch,
  298. BaseFormMeasure,
  299. BaseFormLocation,
  300. BaseFormStatusLog
  301. },
  302. props: {
  303. filter: {
  304. type: Number,
  305. default: -1
  306. },
  307. useType: {
  308. type: Number,
  309. default: null
  310. },
  311. correctType: {
  312. type: Number,
  313. default: 1
  314. },
  315. measureStatus: {
  316. type: Number,
  317. default: null
  318. },
  319. isMeasure: {
  320. type: Number,
  321. default: null
  322. },
  323. isSelf: {
  324. type: Number,
  325. default: null
  326. },
  327. status: {
  328. type: Number,
  329. default: null
  330. }
  331. },
  332. data () {
  333. return {
  334. // 查询参数
  335. queryParam: {
  336. filter: this.filter,
  337. useType: this.useType,
  338. measureStatus: this.measureStatus,
  339. isMeasure: this.isMeasure,
  340. isSelf: this.isSelf,
  341. id: this.$route.query.id,
  342. typeId: this.$route.query.typeId,
  343. status: this.$route.query.status || this.status
  344. },
  345. depreciationTypeMap: {},
  346. visible: true,
  347. dateRange: [],
  348. dateRangeCheck: [],
  349. sbPositionData: [],
  350. levelMap: {},
  351. lineMap: {},
  352. unitMap: {},
  353. areaList: {},
  354. companyList: {},
  355. projectList: {},
  356. isChildMap: {},
  357. isShowMap: {},
  358. deptList: {},
  359. confirmLoading: false,
  360. useTypeMap: {},
  361. statusMap: {},
  362. expandedKeys: [],
  363. selectedKeys: [],
  364. sourceTypeMap: {},
  365. treeData: [],
  366. // 表头
  367. columns: [
  368. /* {
  369. title: '序号',
  370. dataIndex: 'index',
  371. width: 100,
  372. checked: true,
  373. customRender: (text, record, index) => {
  374. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  375. }
  376. }, */
  377. {
  378. title: '设备编号',
  379. dataIndex: 'no',
  380. width: 150,
  381. checked: true
  382. },
  383. {
  384. title: '设备名称',
  385. checked: true,
  386. width: 200,
  387. dataIndex: 'name'
  388. },
  389. {
  390. title: '设备位号',
  391. dataIndex: 'positionNo',
  392. width: 150,
  393. checked: true
  394. },
  395. {
  396. title: '父位号',
  397. dataIndex: 'ppNo',
  398. width: 120,
  399. checked: true
  400. },
  401. {
  402. title: '设备类型',
  403. checked: true,
  404. dataIndex: 'type',
  405. width: 150,
  406. customRender: (text, record, index) => {
  407. return record.typeName
  408. }
  409. },
  410. /* {
  411. title: '设备等级',
  412. checked: true,
  413. dataIndex: 'level',
  414. width: 120,
  415. customRender: (text, record, index) => {
  416. return this.BaseTool.Object.getField(this.levelMap, text)
  417. }
  418. }, */
  419. {
  420. title: '规格型号',
  421. dataIndex: 'model',
  422. width: 150,
  423. checked: true
  424. },
  425. /* {
  426. title: '自定义类型',
  427. checked: true,
  428. dataIndex: 'useType',
  429. width: 150,
  430. customRender: (text, record, index) => {
  431. return this.BaseTool.Object.getField(this.useTypeMap, text)
  432. }
  433. }, */
  434. {
  435. title: '设备位置',
  436. checked: true,
  437. width: 200,
  438. dataIndex: 'positionName'
  439. },
  440. /* {
  441. title: '使用机台',
  442. checked: true,
  443. width: 200,
  444. dataIndex: 'saveUserName'
  445. },
  446. {
  447. title: '生产商',
  448. dataIndex: 'producerId',
  449. width: 120,
  450. checked: true
  451. }, */
  452. /* {
  453. title: '大小尺寸',
  454. dataIndex: 'zz',
  455. width: 120,
  456. checked: true
  457. }, */
  458. {
  459. title: '出厂编号',
  460. dataIndex: 'zzh',
  461. width: 120,
  462. checked: true
  463. },
  464. /* {
  465. title: '是否显示',
  466. dataIndex: 'isShow',
  467. width: 120,
  468. checked: true,
  469. customRender: (text, record, index) => {
  470. return this.BaseTool.Object.getField(this.isShowMap, text)
  471. }
  472. }, */
  473. /* {
  474. title: '是否子设备',
  475. dataIndex: 'isChild',
  476. width: 120,
  477. checked: true,
  478. customRender: (text, record, index) => {
  479. return this.BaseTool.Object.getField(this.isChildMap, text)
  480. }
  481. }, */
  482. /* {
  483. title: '资产编号',
  484. dataIndex: 'financingNo',
  485. width: 120,
  486. checked: true
  487. },
  488. {
  489. title: '设备原值',
  490. dataIndex: 'initialValue',
  491. width: 100,
  492. checked: true,
  493. customRender: (text, record, index) => {
  494. return this.BaseTool.Amount.formatter(text)
  495. }
  496. },
  497. {
  498. title: '购置日期',
  499. dataIndex: 'buyDate',
  500. width: 120,
  501. checked: true
  502. },
  503. {
  504. title: '投用日期',
  505. dataIndex: 'startDate',
  506. width: 120,
  507. checked: true
  508. }, */
  509. /* {
  510. title: '检定日期',
  511. dataIndex: 'checkDate',
  512. width: 150,
  513. checked: true
  514. },
  515. {
  516. title: '检定周期',
  517. dataIndex: 'checkPeriod',
  518. width: 100,
  519. checked: true,
  520. customRender: (text, record, index) => {
  521. if (record.nextCheckDate == null) {
  522. return '未知'
  523. } else {
  524. return text + '月'
  525. }
  526. }
  527. }, */
  528. {
  529. title: '检定有效期',
  530. dataIndex: 'nextCheckDate',
  531. fixed: 'right',
  532. width: 150,
  533. checked: true
  534. },
  535. /* {
  536. title: '检定截止',
  537. dataIndex: 'restDay',
  538. width: 100,
  539. checked: true,
  540. customRender: (text, record, index) => {
  541. if (record.nextCheckDate == null) {
  542. return '未知'
  543. } else {
  544. return this.BaseTool.Date.getCountBetween(new Date(), record.nextCheckDate, 1) + '天'
  545. }
  546. }
  547. }, */
  548. {
  549. title: '状态',
  550. checked: true,
  551. dataIndex: 'status',
  552. fixed: 'right',
  553. width: 100,
  554. scopedSlots: { customRender: 'status' }
  555. },
  556. {
  557. title: '操作',
  558. key: 'action',
  559. checked: true,
  560. fixed: 'right',
  561. align: 'center',
  562. width: '120',
  563. scopedSlots: { customRender: 'action' }
  564. }
  565. ],
  566. // 加载数据方法 必须为 Promise 对象
  567. loadData: parameter => {
  568. parameter = {
  569. ...parameter,
  570. ...this.queryParam,
  571. dataScope: {
  572. sortBy: 'asc',
  573. sortName: 'no'
  574. }
  575. }
  576. return getSbInfoPage(Object.assign(parameter, this.queryParam))
  577. .then(res => {
  578. return res.data
  579. })
  580. },
  581. selectedRowKeys: [],
  582. selectedRows: [],
  583. options: {
  584. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  585. rowSelection: {
  586. selectedRowKeys: this.selectedRowKeys,
  587. onChange: this.onSelectChange
  588. }
  589. },
  590. optionAlertShow: false
  591. }
  592. },
  593. created () {
  594. console.log('this.$route.query.parentId: ' + this.$route.query.parentId)
  595. this.queryParam.parentId = this.$route.query.parentId
  596. this.queryParam.parentName = this.$route.query.parentName
  597. this.tableOption()
  598. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  599. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  600. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  601. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  602. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  603. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  604. this.isChildMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_CHILD)
  605. this.isShowMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_SHOW)
  606. this.lineMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_LINE)
  607. querySbPosition().then(res => {
  608. this.sbPositionData = res.data
  609. })
  610. },
  611. methods: {
  612. tableOption () {
  613. this.setTree()
  614. if (!this.optionAlertShow) {
  615. this.options = {
  616. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  617. rowSelection: {
  618. selectedRowKeys: this.selectedRowKeys,
  619. onChange: this.onSelectChange,
  620. getCheckboxProps: record => ({
  621. props: {
  622. disabled: false,
  623. name: record.id
  624. }
  625. })
  626. }
  627. }
  628. this.optionAlertShow = true
  629. } else {
  630. this.options = {
  631. alert: false,
  632. rowSelection: null
  633. }
  634. this.optionAlertShow = false
  635. }
  636. },
  637. batchDelete (id) {
  638. let ids = []
  639. if (this.BaseTool.String.isBlank(id)) {
  640. const length = this.selectedRows.length
  641. if (length === 0) {
  642. this.$message.info('请选择要删除的记录')
  643. return
  644. }
  645. ids = this.selectedRows.map(item => item.id)
  646. } else {
  647. ids = [id]
  648. }
  649. deleteSbInfos(ids).then(res => {
  650. this.$message.info('删除成功')
  651. this.handleOk()
  652. this.$refs.table.clearSelected()
  653. })
  654. },
  655. batchGenerate () {
  656. this.confirmLoading = true
  657. this.$message.info('正在生成请稍后')
  658. generateSbCodeAll().then(res => {
  659. this.confirmLoading = false
  660. this.$message.info('生成成功')
  661. this.handleOk()
  662. this.$refs.table.clearSelected()
  663. })
  664. },
  665. handleEdit (record) {
  666. fetchSbInfo({ id: record.id }).then(res => {
  667. this.visible = false
  668. const modal = this.$refs.baseModal
  669. modal.base(res.data)
  670. })
  671. },
  672. handlePrint (record) {
  673. this.visible = false
  674. fetchSbInfo({ id: record.id }).then(res => {
  675. const modal = this.$refs.printInSbInfoBatch
  676. modal.base([res.data])
  677. })
  678. },
  679. batchLocation () {
  680. let ids = []
  681. const length = this.selectedRows.length
  682. if (length === 0) {
  683. this.$message.info('请选择设备')
  684. return
  685. }
  686. ids = this.selectedRows.map(item => item.id)
  687. console.log(ids)
  688. batchLocationList({ ids }).then(res => {
  689. this.visible = false
  690. const modal = this.$refs.baseFormLocation
  691. modal.base(res.data)
  692. })
  693. },
  694. batchIncorrect (id) {
  695. let ids = []
  696. if (this.BaseTool.String.isBlank(id)) {
  697. const length = this.selectedRows.length
  698. if (length === 0) {
  699. this.$message.info('请选择要填报的设备')
  700. return
  701. }
  702. ids = this.selectedRows
  703. } else {
  704. ids = [id]
  705. }
  706. console.log(ids)
  707. this.visible = false
  708. const modal = this.$refs.baseModalMeasure
  709. modal.base(ids, this.correctType)
  710. },
  711. handleMeasureBatch () {
  712. const modal = this.$refs.detailSbMeasureModal
  713. modal.base()
  714. },
  715. handlePrintBatch () {
  716. this.visible = false
  717. let ids = []
  718. const length = this.selectedRows.length
  719. if (length === 0) {
  720. this.$message.info('请选择要打印的设备')
  721. return
  722. }
  723. ids = this.selectedRows.map(item => item.id)
  724. fetchSbInfos(ids).then(res => {
  725. const modal = this.$refs.printInSbInfoBatch
  726. modal.base(res.data)
  727. })
  728. },
  729. handleStart (record) {
  730. const modal = this.$refs.baseModalStatusLog
  731. modal.base(null, {
  732. sbId: record.id,
  733. sbNo: record.no,
  734. changeUserId: this.$store.getters.userInfo.userId,
  735. actualUser: this.$store.getters.userInfo.realName,
  736. preStatus: record.status,
  737. afterStatus: this.DictCache.VALUE.SB_INFO_STATUS.IN_USE
  738. })
  739. },
  740. handleStop (record) {
  741. const modal = this.$refs.baseModalStatusLog
  742. modal.base(null, {
  743. sbId: record.id,
  744. sbNo: record.no,
  745. changeUserId: this.$store.getters.userInfo.userId,
  746. actualUser: this.$store.getters.userInfo.realName,
  747. preStatus: record.status,
  748. afterStatus: this.DictCache.VALUE.SB_INFO_STATUS.IN_STOP
  749. })
  750. },
  751. handleAdd () {
  752. this.visible = false
  753. this.$refs.baseModal.base()
  754. },
  755. handleView (record) {
  756. fetchSbInfo({ id: record.id }).then(res => {
  757. this.visible = false
  758. const modal = this.$refs.detailModal
  759. modal.base(res.data)
  760. })
  761. },
  762. handleCopy (record) {
  763. this.visible = false
  764. fetchSbInfo({ id: record.id }).then(res => {
  765. const modal = this.$refs.baseModal
  766. modal.base(res.data, 1)
  767. })
  768. },
  769. handleOk () {
  770. this.visible = true
  771. this.setTree()
  772. if (this.dateRange != null) {
  773. this.queryParam.nextCheckDateStart = this.dateRange[0]
  774. this.queryParam.nextCheckDateEnd = this.dateRange[1]
  775. this.queryParam.nextCheckDateStart = this.queryParam.nextCheckDateStart ? this.queryParam.nextCheckDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  776. this.queryParam.nextCheckDateEnd = this.queryParam.nextCheckDateEnd ? this.queryParam.nextCheckDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  777. }
  778. if (this.dateRangeCheck != null) {
  779. this.queryParam.checkDateStart = this.dateRangeCheck[0]
  780. this.queryParam.checkDateEnd = this.dateRangeCheck[1]
  781. this.queryParam.checkDateStart = this.queryParam.checkDateStart ? this.queryParam.checkDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  782. this.queryParam.checkDateEnd = this.queryParam.checkDateEnd ? this.queryParam.checkDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
  783. }
  784. this.$refs.table.refresh()
  785. },
  786. onSelectChange (selectedRowKeys, selectedRows) {
  787. this.selectedRowKeys = selectedRowKeys
  788. this.selectedRows = selectedRows
  789. },
  790. resetSearchForm () {
  791. this.queryParam = {
  792. filter: this.filter,
  793. useType: this.useType,
  794. measureStatus: this.measureStatus,
  795. isMeasure: this.isMeasure,
  796. isSelf: this.isSelf,
  797. id: this.$route.query.id,
  798. typeId: this.$route.query.typeId,
  799. status: this.$route.query.status || this.status
  800. }
  801. this.visible = true
  802. this.$refs.table.refresh(true)
  803. },
  804. doExport () {
  805. const parameter = {
  806. ...this.queryParam,
  807. sbIds: this.selectedRowKeys,
  808. dataScope: {
  809. sortBy: 'asc',
  810. sortName: 'no'
  811. }
  812. }
  813. console.log(parameter)
  814. exportSbInfo(parameter).then(file => {
  815. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  816. })
  817. },
  818. setTree (record = {}) {
  819. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  820. this.areaList = res.data
  821. })
  822. fetchSbTypeTree().then(res => {
  823. this.treeData = res.data
  824. })
  825. },
  826. onSelect: function (selectedKeys, info) {
  827. this.selectedKeys = selectedKeys
  828. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  829. this.$refs.table.refresh(true)
  830. },
  831. onExpand (expanded, record) { // expanded判断展开or收缩操作,record当前行数据
  832. console.log(expanded)
  833. if (expanded) {
  834. querySbInfo({ positionNo: record.positionNo }).then(res => {
  835. record.children = res.data
  836. })
  837. }
  838. },
  839. doImport () {
  840. this.$refs.importModal.base(null, null)
  841. },
  842. doImportStandard () {
  843. // this.$refs.importModalStandard.base()
  844. this.$refs.importModalUpdate.base(null, 1)
  845. },
  846. doImportForUpdate () {
  847. this.$refs.importModalUpdate.base(null, 2)
  848. }
  849. }
  850. }
  851. </script>