DetailSbCheck.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div v-show="visible">
  3. <a-row :gutter="48" slot="extra">
  4. <a-col :md="48" :sm="48">
  5. <span class="table-page-search-submitButtons" style="float: right">
  6. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  7. </span>
  8. </a-col>
  9. </a-row>
  10. <title-divider title="设备信息" width="90px"></title-divider>
  11. <detail-list title="" :col="3">
  12. <detail-list-item term="设备新号">{{ model.no }}</detail-list-item>
  13. <detail-list-item term="设备旧号">{{ model.zbh }}</detail-list-item>
  14. <detail-list-item term="型号">{{ model.model }}</detail-list-item>
  15. <detail-list-item term="设备名称">{{ model.name }}</detail-list-item>
  16. </detail-list>
  17. <title-divider title="保养信息" width="90px"></title-divider>
  18. <div class="table-operator" style="margin-bottom:8px;">
  19. <a-button type="primary" @click="handleAdd">
  20. <a-icon type="plus"/>
  21. 添加
  22. </a-button>
  23. <a-button style="margin-left:8px;" type="primary" @click="handleSbSelect">
  24. <a-icon type="plus"/>
  25. 复制
  26. </a-button>
  27. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  28. <a-icon type="upload"/>
  29. 新增导入
  30. </a-button>
  31. <a-button style="margin-left:8px;" type="primary" v-if="selectedRowKeys.length > 0" @click="batchDelete">
  32. <a-icon type="delete"/>
  33. 删除
  34. </a-button>
  35. <a-form-item style="margin-left:8px;" label="维护等级">
  36. <a-select v-model="queryParam.level" placeholder="请选择">
  37. <a-select-option
  38. v-for="(label,value) in levelMap"
  39. :key="value"
  40. :label="label"
  41. @change="changeLevel"
  42. :value="parseInt(value)">{{ label }}
  43. </a-select-option>
  44. </a-select>
  45. </a-form-item>
  46. <!-- <a-button style="margin-left: 8px" type="primary" icon="download" @click="doExport">导出</a-button>-->
  47. </div>
  48. <a-table
  49. :data-source="data"
  50. :columns="columns"
  51. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  52. tableLayout="auto"
  53. :scroll="{x: 1100, y: BaseTool.Constant.scrollY}"
  54. rowKey="id">
  55. <span slot="action" slot-scope="record">
  56. <template>
  57. <a v-if="$auth('sb-infos-edit')" @click="handleView(record)">查看</a>
  58. <a-divider type="vertical" />
  59. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  60. <a-divider type="vertical" />
  61. <a @click="handleCopy(record)">复制</a>
  62. <a-divider type="vertical" />
  63. <a @click="handleGenerate(record)">插入任务</a>
  64. </template>
  65. </span>
  66. </a-table>
  67. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  68. <base-form-insert ref="baseModalInsert" @ok="handleOk"/>
  69. <detail ref="detailModal"/>
  70. <sb-info-select-modal :type="'radio'" ref="sbInfoSelectModal" @selected="handleSbSelected"/>
  71. <import-form-add ref="importModal" @ok="handleOk"/>
  72. </div>
  73. </template>
  74. <script>
  75. import DetailList from '@/components/tools/DetailList'
  76. import {
  77. queryCheckStandard,
  78. deleteCheckStandards,
  79. exportCheckStandard,
  80. fetchCheckStandard,
  81. copy
  82. } from '@/api/check/checkstandard'
  83. import BaseForm from './BaseForm'
  84. import BaseFormInsert from './BaseFormInsert'
  85. import Detail from './Detail'
  86. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  87. import ImportFormAdd from '@/views/check/checkstandard/modules/ImportFormAdd'
  88. const DetailListItem = DetailList.Item
  89. export default {
  90. name: 'DetailSbCheck',
  91. components: {
  92. DetailList,
  93. DetailListItem,
  94. BaseForm,
  95. Detail,
  96. SbInfoSelectModal,
  97. BaseFormInsert,
  98. ImportFormAdd
  99. },
  100. props: {
  101. /**
  102. * 检查类型: 1-点检 2-巡检
  103. */
  104. checkType: {
  105. type: Number,
  106. default: 2
  107. }
  108. },
  109. data () {
  110. return {
  111. confirmLoading: false,
  112. mdl: {},
  113. levelMap: {},
  114. model: {
  115. 'id': null,
  116. 'modelId': null,
  117. 'no': null,
  118. 'zbh': null,
  119. 'name': null,
  120. 'nameModel': null,
  121. 'unit': null,
  122. 'level': null,
  123. 'useType': null
  124. },
  125. modalTitle: null,
  126. visible: false,
  127. typeMap: {},
  128. selectedRowKeys: [], // Check here to configure the default column
  129. checkUserTypeMap: {},
  130. actionTypeMap: {},
  131. // 表头
  132. columns: [
  133. {
  134. title: '标准编码',
  135. dataIndex: 'no',
  136. checked: true,
  137. width: '120px'
  138. },
  139. {
  140. title: '维护部位',
  141. width: '100px',
  142. checked: true,
  143. dataIndex: 'partName'
  144. },
  145. {
  146. title: '维护等级',
  147. dataIndex: 'level',
  148. width: '100px',
  149. checked: true,
  150. customRender: (text, record, index) => {
  151. return this.BaseTool.Table.getMapText(this.levelMap, text)
  152. }
  153. },
  154. {
  155. title: '标准内容',
  156. dataIndex: 'requirement',
  157. checked: true,
  158. width: '250px',
  159. customRender: (text, record, index) => {
  160. if (text != null) {
  161. if (text.length > 40) {
  162. return text.slice(0, 40)
  163. } else {
  164. return text
  165. }
  166. } else {
  167. return text
  168. }
  169. }
  170. },
  171. {
  172. title: '周期',
  173. dataIndex: 'periodType',
  174. width: '100px',
  175. checked: true,
  176. customRender: (text, record, index) => {
  177. return record.period + this.BaseTool.Table.getMapText(this.periodTypeMap, text)
  178. }
  179. },
  180. /* {
  181. title: '动作类型',
  182. dataIndex: 'actionType',
  183. customRender: (text, record, index) => {
  184. return this.BaseTool.Table.getMapText(this.actionTypeMap, text)
  185. }
  186. }, */
  187. {
  188. title: '标准工时',
  189. width: '100px',
  190. checked: true,
  191. dataIndex: 'standardHours'
  192. },
  193. {
  194. title: '上次执行日期',
  195. dataIndex: 'lastDate',
  196. checked: true,
  197. width: '200px'
  198. },
  199. {
  200. title: '预计下次执行日期',
  201. dataIndex: 'nextDate',
  202. checked: true,
  203. width: '200px'
  204. },
  205. {
  206. title: '操作',
  207. key: 'action',
  208. checked: true,
  209. align: 'center',
  210. width: '250px',
  211. fixed: 'right',
  212. scopedSlots: { customRender: 'action' }
  213. }
  214. ],
  215. data: []
  216. }
  217. },
  218. created () {
  219. // 下拉框map
  220. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  221. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  222. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  223. this.checkUserTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_USER_TYPE)
  224. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  225. },
  226. methods: {
  227. onSelectChange (selectedRowKeys, selectedRows) {
  228. console.log('selectedRowKeys changed: ', selectedRowKeys)
  229. this.selectedRowKeys = selectedRowKeys
  230. },
  231. base (record) {
  232. this.visible = true
  233. this.model = record
  234. this.modalTitle = '详情2'
  235. queryCheckStandard({ sbId: record.id, type: this.checkType }).then(res => {
  236. this.data = res.data
  237. })
  238. },
  239. changeLevel (value) {
  240. queryCheckStandard({ sbId: this.model.id, level: value, type: this.checkType }).then(res => {
  241. this.data = res.data
  242. })
  243. },
  244. handleOk () {
  245. queryCheckStandard({ sbId: this.model.id, type: this.checkType }).then(res => {
  246. this.data = res.data
  247. })
  248. },
  249. handleAdd () {
  250. const modal = this.$refs.baseModal
  251. modal.base(null, this.model.id, this.model.no)
  252. },
  253. handleView (record) {
  254. fetchCheckStandard({ id: record.id }).then(res => {
  255. const modal = this.$refs.detailModal
  256. res.data.partName = record.partName
  257. modal.base(res.data)
  258. })
  259. },
  260. handleEdit (record) {
  261. fetchCheckStandard({ id: record.id }).then(res => {
  262. const modal = this.$refs.baseModal
  263. res.data.sbNo = this.model.no
  264. modal.base(res.data, this.model.id)
  265. })
  266. },
  267. handleCopy (record) {
  268. const modal = this.$refs.baseModal
  269. const data = record
  270. data.id = null
  271. modal.base(data)
  272. },
  273. handleGenerate (record) {
  274. const modal = this.$refs.baseModalInsert
  275. modal.base(null, record.id)
  276. },
  277. handleCancel () {
  278. this.visible = false
  279. this.confirmLoading = false
  280. this.selectedRowKeys = []
  281. this.$emit('ok')
  282. },
  283. batchDelete (id) {
  284. let ids = []
  285. const length = this.selectedRowKeys.length
  286. if (length === 0) {
  287. this.$message.info('请选择记录')
  288. return
  289. }
  290. ids = this.selectedRowKeys
  291. console.log(this.selectedRowKeys[0])
  292. deleteCheckStandards(ids).then(res => {
  293. this.$message.info('删除成功')
  294. this.handleOk()
  295. })
  296. },
  297. doExport () {
  298. const parameter = {
  299. ...this.queryParam
  300. }
  301. parameter.modelId = this.model.id
  302. exportCheckStandard(parameter).then(file => {
  303. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  304. })
  305. },
  306. doImport () {
  307. this.$refs.importModal.base(this.model.no)
  308. },
  309. handleSbSelect () {
  310. this.$refs.sbInfoSelectModal.base()
  311. },
  312. handleSbSelected (keys, rows) {
  313. const [ row ] = rows
  314. // 日期处理
  315. copy({ sbId: this.model.id, copySbId: row.id })
  316. .then((response) => {
  317. this.$message.info(response.data)
  318. this.handleOk()
  319. }).catch(() => {
  320. this.confirmLoading = false
  321. })
  322. }
  323. }
  324. }
  325. </script>