DetailSbCheck.vue 8.7 KB

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