UpkeepPlanList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  8. <a-form-item label="计划编号">
  9. <a-input placeholder="请输入计划编号" v-model="queryParam.plancode"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  13. <a-form-item label="计划名称">
  14. <a-input placeholder="请输入计划名称" v-model="queryParam.planname"></a-input>
  15. </a-form-item>
  16. </a-col>
  17. <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
  18. <a-form-item label="设备类型">
  19. <j-tree-select
  20. ref="treeSelect"
  21. placeholder="请选择设备类型"
  22. v-model="queryParam.equipdefid"
  23. dict="tpm_equipment_tree,name,id"
  24. pidField="parentid"
  25. pidValue="0"
  26. hasChildField="has_child"
  27. >
  28. </j-tree-select>
  29. </a-form-item>
  30. </a-col> -->
  31. <template v-if="toggleSearchStatus">
  32. <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
  33. <a-form-item label="保养项编号">
  34. <a-input placeholder="请输入保养项编号" v-model="queryParam.itemcode"></a-input>
  35. </a-form-item>
  36. </a-col> -->
  37. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  38. <a-form-item label="设备">
  39. <!-- <j-search-select-tag v-model="queryParam.equipmentid" dict="tpm_equipment,equipmentname,id" placeholder="请选择设备"/> -->
  40. <a-select
  41. v-model="queryParam.equipmentid"
  42. placeholder="请输入设备名称或设备编号"
  43. show-search
  44. :filterOption="filterOptions"
  45. @search="searchDevice"
  46. allowClear>
  47. <a-select-option v-for="(item, index) in deviceOptions" :key="index" :value="item.id" :label="item.equipmentname">
  48. <span>{{item.equipmentname}}</span>
  49. <span style="position: absolute;right: 2%;">{{ item.equipmentcode }}</span>
  50. </a-select-option>
  51. </a-select>
  52. <!-- <a-input placeholder="请输入保养项编号" v-model="queryParam.itemcode"></a-input> -->
  53. </a-form-item>
  54. </a-col>
  55. </template>
  56. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  57. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  58. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  59. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  60. <a @click="handleToggleSearch" style="margin-left: 8px">
  61. {{ toggleSearchStatus ? '收起' : '展开' }}
  62. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  63. </a>
  64. </span>
  65. </a-col>
  66. </a-row>
  67. </a-form>
  68. </div>
  69. <!-- 查询区域-END -->
  70. <!-- 操作按钮区域 -->
  71. <div class="table-operator">
  72. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  73. <!-- <a-button type="primary" icon="download" @click="handleExportXls('保养计划')">导出</a-button>
  74. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  75. <a-button type="primary" icon="import">导入</a-button>
  76. </a-upload> -->
  77. <!-- 高级查询区域 -->
  78. <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query> -->
  79. <a-dropdown v-if="selectedRowKeys.length > 0">
  80. <a-menu slot="overlay">
  81. <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
  82. </a-menu>
  83. <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
  84. </a-dropdown>
  85. </div>
  86. <!-- table区域-begin -->
  87. <div>
  88. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  89. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  90. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  91. </div>
  92. <a-table
  93. ref="table"
  94. size="middle"
  95. :scroll="{x:true}"
  96. bordered
  97. rowKey="id"
  98. :columns="columns"
  99. :dataSource="dataSource"
  100. :pagination="ipagination"
  101. :loading="loading"
  102. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  103. class="j-table-force-nowrap"
  104. @change="handleTableChange">
  105. <template slot="status" slot-scope="text, record">
  106. <a-switch :checked= "record.status == 0 ? true : false" @click="statusChange(record,$event)" />
  107. </template>
  108. <template slot="htmlSlot" slot-scope="text">
  109. <div v-html="text"></div>
  110. </template>
  111. <template slot="imgSlot" slot-scope="text,record">
  112. <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
  113. <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
  114. </template>
  115. <template slot="fileSlot" slot-scope="text">
  116. <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
  117. <a-button
  118. v-else
  119. :ghost="true"
  120. type="primary"
  121. icon="download"
  122. size="small"
  123. @click="downloadFile(text)">
  124. 下载
  125. </a-button>
  126. </template>
  127. <span slot="action" slot-scope="text, record">
  128. <a @click="handleEdit(record)">编辑</a>
  129. <a-divider type="vertical" />
  130. <a-dropdown>
  131. <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
  132. <a-menu slot="overlay">
  133. <a-menu-item>
  134. <a @click="handleDetail(record)">详情</a>
  135. </a-menu-item>
  136. <a-menu-item>
  137. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  138. <a>删除</a>
  139. </a-popconfirm>
  140. </a-menu-item>
  141. </a-menu>
  142. </a-dropdown>
  143. </span>
  144. </a-table>
  145. </div>
  146. <upkeep-plan-modal ref="modalForm" @ok="modalFormOk"></upkeep-plan-modal>
  147. </a-card>
  148. </template>
  149. <script>
  150. import '@/assets/less/TableExpand.less'
  151. import { mixinDevice } from '@/utils/mixin'
  152. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  153. import { httpAction, getAction } from '@/api/manage'
  154. import UpkeepPlanModal from './modules/UpkeepPlanModal'
  155. export default {
  156. name: 'UpkeepPlanList',
  157. mixins:[JeecgListMixin, mixinDevice],
  158. components: {
  159. UpkeepPlanModal
  160. },
  161. data () {
  162. return {
  163. description: '保养计划管理页面',
  164. // 表头
  165. columns: [
  166. {
  167. title: '序号',
  168. dataIndex: '',
  169. key:'rowIndex',
  170. width:60,
  171. align:"center",
  172. customRender:function (t,r,index) {
  173. return parseInt(index)+1;
  174. }
  175. },
  176. {
  177. title:'计划编号',
  178. align:"center",
  179. dataIndex: 'plancode'
  180. },
  181. {
  182. title:'计划名称',
  183. align:"center",
  184. dataIndex: 'planname'
  185. },
  186. {
  187. title:'设备',
  188. align:"center",
  189. dataIndex: 'equipmentName'
  190. },
  191. // {
  192. // title:'保养工作项目ID',
  193. // align:"center",
  194. // dataIndex: 'upkeepprojid'
  195. // },
  196. // {
  197. // title:'工作项目名称',
  198. // align:"center",
  199. // dataIndex: 'projectname'
  200. // },
  201. {
  202. title:'地点',
  203. align:"center",
  204. dataIndex: 'address'
  205. },
  206. // {
  207. // title:'厂商名称',
  208. // align:"center",
  209. // dataIndex: 'supplier'
  210. // },
  211. // {
  212. // title:'厂商电话',
  213. // align:"center",
  214. // dataIndex: 'suppliertel'
  215. // },
  216. // {
  217. // title:'联系人',
  218. // align:"center",
  219. // dataIndex: 'linker'
  220. // },
  221. // {
  222. // title:'联系人电话',
  223. // align:"center",
  224. // dataIndex: 'linkertel'
  225. // },
  226. {
  227. title:'负责人',
  228. align:"center",
  229. dataIndex: 'chargeruser_dictText'
  230. },
  231. // {
  232. // title:'描述',
  233. // align:"center",
  234. // dataIndex: 'plandesc'
  235. // },
  236. {
  237. title:'开始时间',
  238. align:"center",
  239. dataIndex: 'begintime',
  240. // customRender:function (text) {
  241. // return !text?"":(text.length>10?text.substr(0,10):text)
  242. // }
  243. },
  244. {
  245. title:'重复间隔',
  246. align:"center",
  247. dataIndex: 'repeatnum'
  248. },
  249. {
  250. title:'间隔单位',
  251. align:"center",
  252. dataIndex: 'repeattype'
  253. },
  254. {
  255. title:'提前通知时长',
  256. align:"center",
  257. dataIndex: 'noticenum'
  258. },
  259. {
  260. title:'时长单位',
  261. align:"center",
  262. dataIndex: 'noticetype'
  263. },
  264. // 状态(0启用 1停用)
  265. {
  266. title:'状态',
  267. align:"center",
  268. dataIndex: 'status',
  269. scopedSlots: { customRender: 'status' }
  270. },
  271. {
  272. title:'下次执行时间',
  273. align:"center",
  274. dataIndex: 'nexttime',
  275. // customRender:function (text) {
  276. // return !text?"":(text.length>10?text.substr(0,10):text)
  277. // }
  278. },
  279. {
  280. title:'下次通知时间',
  281. align:"center",
  282. dataIndex: 'noticetime',
  283. // customRender:function (text) {
  284. // return !text?"":(text.length>10?text.substr(0,10):text)
  285. // }
  286. },
  287. {
  288. title:'通知状态',
  289. align:"center",
  290. dataIndex: 'ifnotice'
  291. },
  292. {
  293. title:'备注',
  294. align:"center",
  295. dataIndex: 'remark'
  296. },
  297. {
  298. title: '操作',
  299. dataIndex: 'action',
  300. align:"center",
  301. fixed:"right",
  302. width:147,
  303. scopedSlots: { customRender: 'action' }
  304. }
  305. ],
  306. url: {
  307. list: "/cmmsUpkeepPlan/cmmsUpkeepPlan/list",
  308. delete: "/cmmsUpkeepPlan/cmmsUpkeepPlan/delete",
  309. deleteBatch: "/cmmsUpkeepPlan/cmmsUpkeepPlan/deleteBatch",
  310. exportXlsUrl: "/cmmsUpkeepPlan/cmmsUpkeepPlan/exportXls",
  311. importExcelUrl: "cmmsUpkeepPlan/cmmsUpkeepPlan/importExcel",
  312. edit: "/cmmsUpkeepPlan/cmmsUpkeepPlan/updateCmmsUpkeepPlanStatusById",
  313. },
  314. dictOptions:{},
  315. superFieldList:[],
  316. model: {},
  317. deviceOptions: [],
  318. deviceOptionsAll: [],
  319. }
  320. },
  321. created() {
  322. this.getSuperFieldList();
  323. this.getDeviceOption();
  324. },
  325. computed: {
  326. importExcelUrl: function(){
  327. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  328. },
  329. },
  330. methods: {
  331. // 获取设备下拉列表
  332. getDeviceOption(){
  333. getAction(`/tpmEquipment/tpmEquipment/selectEquipmentList`).then(res=>{
  334. console.log(111,res.result)
  335. this.deviceOptions = res.result.map((res) => {
  336. return {
  337. id: res.id,
  338. equipmentname: res.equipmentname,
  339. equipmentcode: res.equipmentcode,
  340. }
  341. })
  342. // 存一个完整的设备表
  343. this.deviceOptionsAll = this.deviceOptions
  344. console.log(7878,this.deviceOptionsAll)
  345. })
  346. },
  347. // 筛选设备
  348. searchDevice(value) {
  349. console.log(1212,value,value.trim().length)
  350. // 若输入的值删除,则重新赋完整的设备列表
  351. if (value.trim().length === 0) {
  352. this.deviceOptions = this.deviceOptionsAll
  353. }
  354. // 通过判断字符串中是数字还是文字进而判断是通过设备名筛选还是设备编号筛选
  355. let panDuan = isNaN(parseFloat(value))
  356. if (!panDuan) {
  357. // 数字
  358. console.log(777)
  359. let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentcode.includes(value));
  360. this.deviceOptions = filteredArray
  361. } else {
  362. console.log(888)
  363. let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentname.includes(value));
  364. this.deviceOptions = filteredArray
  365. }
  366. console.log(999,this.deviceOptions)
  367. },
  368. // 解决筛选后option不回显问题
  369. filterOptions(input, option) {
  370. return this.deviceOptions
  371. },
  372. initDictConfig(){
  373. },
  374. getSuperFieldList(){
  375. let fieldList=[];
  376. fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
  377. fieldList.push({type:'string',value:'plancode',text:'保养计划编号',dictCode:''})
  378. fieldList.push({type:'string',value:'planname',text:'保养计划名称',dictCode:''})
  379. fieldList.push({type:'string',value:'upkeepprojid',text:'保养工作项目ID',dictCode:''})
  380. fieldList.push({type:'string',value:'projectname',text:'工作项目名称',dictCode:''})
  381. fieldList.push({type:'string',value:'address',text:'地点',dictCode:''})
  382. fieldList.push({type:'string',value:'supplier',text:'厂商名称',dictCode:''})
  383. fieldList.push({type:'string',value:'suppliertel',text:'厂商电话',dictCode:''})
  384. fieldList.push({type:'string',value:'linker',text:'联系人',dictCode:''})
  385. fieldList.push({type:'string',value:'linkertel',text:'联系人电话',dictCode:''})
  386. fieldList.push({type:'string',value:'chargeruser',text:'负责人',dictCode:''})
  387. fieldList.push({type:'string',value:'plandesc',text:'描述',dictCode:''})
  388. fieldList.push({type:'date',value:'begintime',text:'开始时间'})
  389. fieldList.push({type:'int',value:'repeatnum',text:'重复',dictCode:''})
  390. fieldList.push({type:'string',value:'repeattype',text:'重复类型:年、月、周、日、时、分',dictCode:''})
  391. fieldList.push({type:'int',value:'noticenum',text:'提前通知时间',dictCode:''})
  392. fieldList.push({type:'string',value:'noticetype',text:'提前通知类型:天、时、分',dictCode:''})
  393. fieldList.push({type:'string',value:'status',text:'状态(0启用 1停用)',dictCode:''})
  394. fieldList.push({type:'date',value:'nexttime',text:'下次执行时间'})
  395. fieldList.push({type:'date',value:'noticetime',text:'下次通知时间'})
  396. fieldList.push({type:'string',value:'ifnotice',text:'是否已通知:是/否',dictCode:''})
  397. fieldList.push({type:'string',value:'equipmentid',text:'设备id(根据设备id查找保养项内容)',dictCode:''})
  398. this.superFieldList = fieldList
  399. },
  400. statusChange(record,$event){
  401. console.log(record.status,$event)
  402. let text1 = record.status === "0" ? "是否确认停用“" : "是否确认使用“";
  403. let text2 = record.status === "0" ? "”,请确保该设备有可使用的保养计划" : "”,若启用当前保养计划则该设备其他保养计划默认禁用";
  404. const that = this
  405. that.$confirm({
  406. title: "提示",
  407. content: text1 + record.planname + text2,
  408. onOk() {
  409. let httpurl = '';
  410. let method = 'put';
  411. httpurl+=that.url.edit;
  412. if (record.status == 1) {
  413. that.model.id = record.id
  414. that.model.equipmentid = record.equipmentid
  415. that.model.status = 0
  416. } else {
  417. that.model.id = record.id
  418. that.model.equipmentid = record.equipmentid
  419. that.model.status = 1
  420. }
  421. console.log("0101",that.model)
  422. httpAction(httpurl,that.model,method).then((res)=>{
  423. if(res.success){
  424. that.$message.success(res.message);
  425. that.modalFormOk()
  426. }else{
  427. that.$message.warning(res.message);
  428. }
  429. })
  430. },
  431. onCancel() {
  432. // that.modalFormOk()
  433. }
  434. });
  435. }
  436. }
  437. }
  438. </script>
  439. <style scoped>
  440. @import '~@assets/less/common.less';
  441. </style>