DetailSbCheck.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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">
  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" icon="download" @click="doExport">导出</a-button>-->
  28. </div>
  29. <a-table
  30. :data-source="data"
  31. :columns="columns"
  32. tableLayout="auto"
  33. rowKey="id">
  34. <span slot="action" slot-scope="record">
  35. <template>
  36. <a v-if="$auth('sb-infos-edit')" @click="handleView(record)">查看</a>
  37. <a-divider type="vertical" />
  38. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  39. <a-divider type="vertical" />
  40. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  41. <a>删除</a>
  42. </a-popconfirm>
  43. <a-divider type="vertical" />
  44. <a @click="handleCopy(record)">复制</a>
  45. <a-divider type="vertical" />
  46. <a @click="handleGenerate(record)">插入任务</a>
  47. </template>
  48. </span>
  49. </a-table>
  50. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  51. <base-form-insert ref="baseModalInsert" @ok="handleOk"/>
  52. <detail ref="detailModal"/>
  53. <sb-info-select-modal :type="'radio'" ref="sbInfoSelectModal" @selected="handleSbSelected"/>
  54. </div>
  55. </template>
  56. <script>
  57. import DetailList from '@/components/tools/DetailList'
  58. import {
  59. queryCheckStandard,
  60. deleteCheckStandards,
  61. exportCheckStandard,
  62. fetchCheckStandard,
  63. copy,
  64. generateJobByCheckStandard
  65. } from '@/api/check/checkstandard'
  66. import BaseForm from './BaseForm'
  67. import BaseFormInsert from './BaseFormInsert'
  68. import Detail from './Detail'
  69. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  70. const DetailListItem = DetailList.Item
  71. export default {
  72. name: 'DetailSbCheck',
  73. components: {
  74. DetailList,
  75. DetailListItem,
  76. BaseForm,
  77. Detail,
  78. SbInfoSelectModal,
  79. BaseFormInsert
  80. },
  81. props: {
  82. /**
  83. * 检查类型: 1-点检 2-巡检
  84. */
  85. checkType: {
  86. type: Number,
  87. default: 2
  88. }
  89. },
  90. data () {
  91. return {
  92. confirmLoading: false,
  93. mdl: {},
  94. model: {
  95. 'id': null,
  96. 'modelId': null,
  97. 'no': null,
  98. 'zbh': null,
  99. 'name': null,
  100. 'nameModel': null,
  101. 'unit': null,
  102. 'level': null,
  103. 'useType': null
  104. },
  105. modalTitle: null,
  106. visible: false,
  107. typeMap: {},
  108. actionTypeMap: {},
  109. // 表头
  110. columns: [
  111. {
  112. title: '序号',
  113. dataIndex: 'index',
  114. customRender: (text, record, index) => {
  115. return index + 1
  116. }
  117. },
  118. {
  119. title: '名称',
  120. dataIndex: 'name'
  121. },
  122. {
  123. title: '检查部位',
  124. dataIndex: 'partName'
  125. },
  126. {
  127. title: '周期',
  128. dataIndex: 'periodType',
  129. customRender: (text, record, index) => {
  130. return record.period + this.BaseTool.Table.getMapText(this.periodTypeMap, text)
  131. }
  132. },
  133. {
  134. title: '动作类型',
  135. dataIndex: 'actionType',
  136. customRender: (text, record, index) => {
  137. return this.BaseTool.Table.getMapText(this.actionTypeMap, text)
  138. }
  139. },
  140. {
  141. title: '标准工时',
  142. dataIndex: 'standardHours'
  143. },
  144. {
  145. title: '操作',
  146. key: 'action',
  147. checked: true,
  148. align: 'center',
  149. // fixed: 'right',
  150. scopedSlots: { customRender: 'action' }
  151. }
  152. ],
  153. data: []
  154. }
  155. },
  156. created () {
  157. // 下拉框map
  158. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  159. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  160. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  161. },
  162. methods: {
  163. base (record) {
  164. this.visible = true
  165. this.model = record
  166. this.modalTitle = '详情2'
  167. queryCheckStandard({ sbId: record.id, type: this.checkType }).then(res => {
  168. this.data = res.data
  169. })
  170. },
  171. handleOk () {
  172. queryCheckStandard({ sbId: this.model.id, type: this.checkType }).then(res => {
  173. this.data = res.data
  174. })
  175. },
  176. handleAdd () {
  177. const modal = this.$refs.baseModal
  178. modal.base(null, this.model.id)
  179. },
  180. handleView (record) {
  181. fetchCheckStandard({ id: record.id }).then(res => {
  182. const modal = this.$refs.detailModal
  183. res.data.partName = record.partName
  184. modal.base(res.data)
  185. })
  186. },
  187. handleEdit (record) {
  188. fetchCheckStandard({ id: record.id }).then(res => {
  189. const modal = this.$refs.baseModal
  190. modal.base(res.data)
  191. })
  192. },
  193. handleCopy (record) {
  194. const modal = this.$refs.baseModal
  195. const data = record
  196. data.id = null
  197. modal.base(data)
  198. },
  199. handleGenerate (record) {
  200. const modal = this.$refs.baseModalInsert
  201. modal.base(null, record.id)
  202. },
  203. handleCancel () {
  204. this.visible = false
  205. this.confirmLoading = false
  206. this.$emit('ok')
  207. },
  208. batchDelete (id) {
  209. let ids = []
  210. if (this.BaseTool.String.isBlank(id)) {
  211. if (length === 0) {
  212. this.$message.info('请选择要删除的记录')
  213. return
  214. }
  215. ids = this.selectedRows.map(item => item.id)
  216. } else {
  217. ids = [id]
  218. }
  219. deleteCheckStandards(ids).then(res => {
  220. this.$message.info('删除成功')
  221. this.handleOk()
  222. })
  223. },
  224. doExport () {
  225. const parameter = {
  226. ...this.queryParam
  227. }
  228. parameter.modelId = this.model.id
  229. exportCheckStandard(parameter).then(file => {
  230. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  231. })
  232. },
  233. handleSbSelect () {
  234. this.$refs.sbInfoSelectModal.base()
  235. },
  236. handleSbSelected (keys, rows) {
  237. const [ key ] = keys
  238. const [ row ] = rows
  239. // 日期处理
  240. copy({ sbId: this.model.id, copySbId: row.id })
  241. .then((response) => {
  242. this.$message.info(response.data)
  243. this.handleOk()
  244. }).catch(() => {
  245. this.confirmLoading = false
  246. })
  247. }
  248. }
  249. }
  250. </script>