斯瑞奇mes前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

571 lines
17 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;">
  4. <el-button @click="getData()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'查询'}}</el-button>
  5. <el-button @click="addModal()" type="primary" style="margin-left: 2px;margin-top: 0px">{{'新增'}}</el-button>
  6. <download-excel
  7. :fields="fields()"
  8. :data="exportData"
  9. type="xls"
  10. :name="exportName"
  11. :header="exportHeader"
  12. :footer="exportFooter"
  13. :fetch="createExportData"
  14. :before-generate="startDownload"
  15. :before-finish="finishDownload"
  16. worksheet="导出信息"
  17. class="el-button el-button--primary el-button--medium">
  18. {{ buttons.download }}
  19. </download-excel>
  20. </el-form>
  21. <el-table
  22. :height="height"
  23. :data="dataList"
  24. border
  25. v-loading="dataListLoading"
  26. style="width: 100%;">
  27. <el-table-column
  28. header-align="center"
  29. align="center"
  30. width="100"
  31. label="操作">
  32. <template slot-scope="scope">
  33. <a type="text" size="small" @click="editModal(scope.row)">编辑</a>
  34. <a type="text" size="small" @click="deleteModal(scope.row)">删除</a>
  35. </template>
  36. </el-table-column>
  37. <el-table-column
  38. v-for="(item,index) in columnList" :key="index"
  39. :sortable="item.columnSortable"
  40. :prop="item.columnProp"
  41. :header-align="item.headerAlign"
  42. :show-overflow-tooltip="item.showOverflowTooltip"
  43. :align="item.align"
  44. :fixed="item.fixed==''?false:item.fixed"
  45. :min-width="item.columnWidth"
  46. :label="item.columnLabel">
  47. <template slot-scope="scope">
  48. <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
  49. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  50. style="width: 100px; height: 80px"/></span>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <el-dialog title="班次信息维护" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="470px" >
  55. <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
  56. <el-form-item :label="'工厂编码:'">
  57. <el-input v-model="modalData.site" :disabled="InputFlag" style="width: 130px"></el-input>
  58. </el-form-item>
  59. <el-form-item :label="'班次编码:'">
  60. <el-input v-model="modalData.shiftNo" :disabled="InputFlag" style="width: 130px"></el-input>
  61. </el-form-item>
  62. <el-form-item :label="'班次名称:'">
  63. <el-input v-model="modalData.shiftDesc" style="width: 130px"></el-input>
  64. </el-form-item>
  65. </el-form>
  66. <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
  67. <el-form-item :label="'上班时间:'">
  68. <el-time-picker
  69. format="HH:mm"
  70. style="width: 130px"
  71. v-model="modalData.startexacttime"
  72. placeholder="请选择"
  73. value-format="HH:mm">
  74. </el-time-picker>
  75. </el-form-item>
  76. <el-form-item :label="'下班时间:'">
  77. <el-time-picker
  78. format="HH:mm"
  79. style="width: 130px"
  80. v-model="modalData.endexacttime"
  81. placeholder="请选择"
  82. value-format="HH:mm">
  83. </el-time-picker>
  84. </el-form-item>
  85. </el-form>
  86. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  87. <el-button type="primary" @click="modalSave()">保存</el-button>
  88. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  89. </el-footer>
  90. </el-dialog>
  91. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  92. </div>
  93. </template>
  94. <script>
  95. import {
  96. getShiftData,
  97. shiftSave,
  98. deleteShift,
  99. } from "@/api/base/site.js"
  100. import {
  101. searchSysLanguagePackList,
  102. searchSysLanguageParam,
  103. searchFunctionButtonList,
  104. saveButtonList,
  105. searchSysLanguage,
  106. searchLanguageListByLanguageCode,
  107. saveSysLanguageOne,
  108. searchPageLanguageData,
  109. removerLanguage
  110. } from "@/api/sysLanguage.js"
  111. import {
  112. saveTableDefaultList,
  113. saveTableUser,
  114. getTableDefaultListLanguage,
  115. getTableUserListLanguage,
  116. removerDefault,
  117. removerUser
  118. } from "@/api/table.js"
  119. import Chooselist from '@/views/modules/common/Chooselist'
  120. export default {
  121. name: "factoryInformation",
  122. components: {
  123. Chooselist
  124. },
  125. data() {
  126. return {
  127. tagNo:'',
  128. // 导出 start
  129. exportData: [],
  130. exportName: "班次信息"+this.dayjs().format('YYYYMMDDHHmmss'),
  131. exportHeader: ["班次信息"],
  132. exportFooter: [],
  133. // 导出 end
  134. // 多语言 start
  135. buttonList: [
  136. ],
  137. showDefault:false,
  138. // 语言词典集合
  139. sysLanguageParams: [],
  140. dataListLoading: false,
  141. // 用户table 配置集合
  142. userColumnList: [],
  143. queryTableUser: {
  144. userId: this.$store.state.user.name,
  145. functionId: this.$route.meta.menuId,
  146. tableId: "100003Table",
  147. status: true,
  148. languageCode: this.$i18n.locale
  149. },
  150. buttons:{
  151. defaultTable:'设置默认配置',
  152. search:'查询',
  153. download:'导出',
  154. settingTable: '设置列表',
  155. site:'工厂编码',
  156. active:'在用',
  157. all:'全部',
  158. yes:'是',
  159. no:'否',
  160. partNo:'物料编码',
  161. partDescription:'物料名称',
  162. spec:'规则型号',
  163. newDate:'新增日期',
  164. to:'至',
  165. },
  166. // 默认table 查询参数
  167. queryTable: {
  168. functionId: this.$route.meta.menuId,
  169. tableId: "100003Table",
  170. languageCode: this.$i18n.locale
  171. },
  172. languageList: [],
  173. queryLanguage: {},
  174. visible:false,
  175. // 多语言 end
  176. height: 200,
  177. dataList:[],
  178. columnList: [
  179. {
  180. userId: this.$store.state.user.name,
  181. functionId: 100003,
  182. serialNumber: '100003TableSite',
  183. tableId: "100003Table",
  184. tableName: "工厂信息表",
  185. columnProp: "site",
  186. headerAlign: "center",
  187. align: "left",
  188. columnLabel: "工厂编码",
  189. columnHidden: false,
  190. columnImage: false,
  191. columnSortable: false,
  192. sortLv: 0,
  193. status: true,
  194. fixed: false,
  195. columnWidth: 60
  196. },
  197. {
  198. userId: this.$store.state.user.name,
  199. functionId: 100003,
  200. serialNumber: '100003TableShiftNo',
  201. tableId: "100003Table",
  202. tableName: "工厂信息表",
  203. columnProp: "shiftNo",
  204. headerAlign: "center",
  205. align: "left",
  206. columnLabel: "班次编码",
  207. columnHidden: false,
  208. columnImage: false,
  209. columnSortable: false,
  210. sortLv: 0,
  211. status: true,
  212. fixed: false,
  213. columnWidth: 60
  214. },
  215. {
  216. userId: this.$store.state.user.name,
  217. functionId: 100003,
  218. serialNumber: '100003TableShiftDesc',
  219. tableId: "100003Table",
  220. tableName: "工厂信息表",
  221. columnProp: "shiftDesc",
  222. headerAlign: "center",
  223. align: "left",
  224. columnLabel: "班次名称",
  225. columnHidden: false,
  226. columnImage: false,
  227. columnSortable: false,
  228. sortLv: 0,
  229. status: true,
  230. fixed: false,
  231. columnWidth: 100
  232. },
  233. {
  234. userId: this.$store.state.user.name,
  235. functionId: 100003,
  236. serialNumber: '100003TableStartexactTime',
  237. tableId: "100003Table",
  238. tableName: "工厂信息表",
  239. columnProp: "startexacttime",
  240. headerAlign: "center",
  241. align: "left",
  242. columnLabel: "开始时间",
  243. columnHidden: false,
  244. columnImage: false,
  245. columnSortable: false,
  246. sortLv: 0,
  247. status: true,
  248. fixed: false,
  249. columnWidth: 80
  250. },
  251. {
  252. userId: this.$store.state.user.name,
  253. functionId: 100003,
  254. serialNumber: '100003TableEndexactTime',
  255. tableId: "100003Table",
  256. tableName: "工厂信息表",
  257. columnProp: "endexacttime",
  258. headerAlign: "center",
  259. align: "left",
  260. columnLabel: "结束时间",
  261. columnHidden: false,
  262. columnImage: false,
  263. columnSortable: false,
  264. sortLv: 0,
  265. status: true,
  266. fixed: false,
  267. columnWidth: 80
  268. },
  269. ],
  270. modalData:{
  271. flag:0,
  272. site:'',
  273. shiftNo:'',
  274. shiftDesc:'',
  275. startexacttime:'',
  276. endexacttime:'',
  277. },
  278. modalFlag:false,
  279. InputFlag:false,
  280. }
  281. },
  282. mounted() {
  283. this.$nextTick(() => {
  284. this.height = window.innerHeight - 140;
  285. })
  286. },
  287. watch: {
  288. '$route' (to, from) {
  289. if(localStorage.getItem('factoryInformation')!=undefined){
  290. this.getData();
  291. }
  292. },
  293. modalData: {
  294. deep: true,
  295. handler: function (newV, oldV) {
  296. this.modalData.shiftNo = this.modalData.shiftNo.toUpperCase()
  297. }
  298. },
  299. },
  300. methods: {
  301. getBaseData(val){
  302. this.$nextTick(() => {
  303. if (this.tagNo === 93) {
  304. this.modalData.companyID = val.CompanyID
  305. }
  306. })
  307. },
  308. // 获取基础数据列表
  309. getBaseList(val){
  310. this.tagNo = val
  311. this.$nextTick(() => {
  312. let strVal = "";
  313. if (val === 93 && this.modalData.companyID){
  314. strVal = this.modalData.companyID
  315. }
  316. this.$refs.baseList.init(val,strVal)
  317. })
  318. },
  319. getData(){
  320. // let data={};
  321. // if(localStorage.getItem('factoryInformation')!=undefined){
  322. // data=JSON.parse(localStorage.getItem('factoryInformation'));
  323. // }
  324. // localStorage.removeItem('factoryInformation');
  325. let data={
  326. site:this.$store.state.user.site
  327. }
  328. getShiftData(data).then(({data}) => {
  329. this.dataList = data.rows
  330. })
  331. },
  332. addModal(){
  333. this.modalData.flag=0;
  334. this.modalData.site=this.$store.state.user.site;
  335. this.modalData.shiftNo='';
  336. this.modalData.shiftDesc='';
  337. this.modalData.startexacttime='';
  338. this.modalData.endexacttime='';
  339. this.InputFlag=false;
  340. this.modalFlag=true;
  341. },
  342. editModal(row){
  343. this.modalData.flag=1;
  344. this.modalData.site=row.site;
  345. this.modalData.shiftNo=row.shiftNo;
  346. this.modalData.shiftDesc=row.shiftDesc;
  347. this.modalData.startexacttime=row.startexacttime;
  348. this.modalData.endexacttime=row.endexacttime;
  349. this.InputFlag=true;
  350. this.modalFlag=true;
  351. },
  352. modalSave(){
  353. if(this.modalData.site==''||this.modalData.site==null){
  354. this.$alert("请选择工厂编码!",'错误',{
  355. confirmButtonText:'确定'
  356. })
  357. return false;
  358. }
  359. if(this.modalData.shiftNo==''||this.modalData.shiftNo==null){
  360. this.$alert("请输入班次编码!",'错误',{
  361. confirmButtonText:'确定'
  362. })
  363. return false;
  364. }
  365. if(this.modalData.shiftDesc==''||this.modalData.shiftDesc==null){
  366. this.$alert("请输入班次名称!",'错误',{
  367. confirmButtonText:'确定'
  368. })
  369. return false;
  370. }
  371. if(this.modalData.startexacttime==''||this.modalData.startexacttime==null){
  372. this.$alert("请输入上班时间!",'错误',{
  373. confirmButtonText:'确定'
  374. })
  375. return false;
  376. }
  377. if(this.modalData.endexacttime==''||this.modalData.endexacttime==null){
  378. this.$alert("请输入下班时间!",'错误',{
  379. confirmButtonText:'确定'
  380. })
  381. return false;
  382. }
  383. shiftSave(this.modalData).then(({data}) => {
  384. if (data && data.code == 0) {
  385. this.modalFlag = false
  386. this.getData();
  387. this.$message({
  388. message: '操作成功',
  389. type: 'success',
  390. duration: 1500,
  391. onClose: () => {
  392. }
  393. })
  394. } else {
  395. this.$alert(data.msg, '错误', {
  396. confirmButtonText: '确定'
  397. })
  398. }
  399. })
  400. },
  401. deleteModal(row){
  402. this.$confirm(`是否删除此条班次记录?`, '提示', {
  403. confirmButtonText: '确定',
  404. cancelButtonText: '取消',
  405. type: 'warning'
  406. }).then(() => {
  407. let daleteData={
  408. site:row.site,
  409. shiftNo:row.shiftNo
  410. }
  411. deleteShift(daleteData).then(({data}) => {
  412. if (data && data.code == 0) {
  413. this.modelFlag = false
  414. this.getData();
  415. this.$message.success('操作成功')
  416. } else {
  417. this.$alert(data.msg, '错误', {
  418. confirmButtonText: '确定'
  419. })
  420. }
  421. })
  422. })
  423. },
  424. //导出excel
  425. createExportData() {
  426. return this.dataList;
  427. },
  428. startDownload() {
  429. // this.exportData = this.dataList
  430. },
  431. finishDownload() {
  432. },
  433. fields() {
  434. let json = "{"
  435. this.columnList.forEach((item, index) => {
  436. if (index == this.columnList.length - 1) {
  437. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  438. } else {
  439. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  440. }
  441. })
  442. json += "}"
  443. let s = eval("(" + json + ")")
  444. return s
  445. },
  446. // 导出 end
  447. getCompanyInformation(row){
  448. let inData={companyID:row.companyID,companyName:row.companyName};
  449. localStorage.setItem('companyInformation', JSON.stringify(inData))
  450. this.$router.replace('base-companyInformation')
  451. },
  452. //多语言start
  453. // 获取页面多语言
  454. getMsgLanguage() {
  455. this.dataListLoading = true
  456. let queryLang = {
  457. functionId: this.$route.meta.menuId,
  458. table_id: '100003Table',
  459. languageCode: this.$i18n.locale
  460. }
  461. searchPageLanguageData(queryLang).then((data) => {
  462. if (JSON.stringify(data.data) != '{}') {
  463. this.pageLanguageData = data.data
  464. } else {
  465. }
  466. })
  467. this.dataListLoading = false
  468. },
  469. // 获取button的词典
  470. getFunctionButtonList() {
  471. searchFunctionButtonList(this.queryTable).then(({data}) => {
  472. if (JSON.stringify(data.data) != '{}') {
  473. this.buttons = data.data
  474. } else {
  475. // saveButtonList(this.buttonList).then(({data}) => {
  476. // })
  477. }
  478. })
  479. },
  480. // 获取语言词典
  481. getSysLanguageParamList() {
  482. searchSysLanguageParam(this.queryTable).then(({data}) => {
  483. this.sysLanguageParams = data.rows
  484. })
  485. },
  486. // 打开页面设置
  487. userSetting() {
  488. this.visible = true;
  489. let queryTable = {
  490. userId: this.$store.state.user.name,
  491. functionId: this.$route.meta.menuId,
  492. tableId: "100003Table",
  493. languageCode: this.$i18n.locale
  494. }
  495. this.$nextTick(() => {
  496. this.$refs.column.init(queryTable);
  497. });
  498. },
  499. // 获取 用户保存的 格式列
  500. getTableUserColumn() {
  501. getTableUserListLanguage(this.queryTableUser).then(({data}) => {
  502. if (data.rows.length>0) {
  503. //this.columnList = []
  504. this.columnList = data.rows
  505. } else {
  506. this.getColumnList()
  507. }
  508. })
  509. },
  510. // 保存 默认配置 列
  511. saveColumnList() {
  512. // 删除所有的该页面下保存的数据
  513. if (this.userColumnList) {
  514. //删除 user自定义的数据
  515. removerUser(this.queryTable)
  516. }
  517. // 删除默认配置
  518. removerDefault(this.queryTable)
  519. // 删除语言
  520. removerLanguage(this.queryTable)
  521. // 保存页面 table属性
  522. let sumColumnList = this.columnList;
  523. saveTableDefaultList(sumColumnList).then(({data}) => {
  524. })
  525. // 保存页面 button label title 属性
  526. saveButtonList(this.buttonList).then(({data}) => {
  527. })
  528. this.getFunctionButtonList()
  529. this.getColumnList()
  530. },
  531. // 获取 tableDefault 列
  532. getColumnList() {
  533. getTableDefaultListLanguage(this.queryTable).then(({data}) => {
  534. if (data.rows.length>0) {
  535. // this.showDefault = false
  536. this.columnList = data.rows
  537. } else {
  538. // this.showDefault = true
  539. }
  540. })
  541. },
  542. //多语言 end
  543. },
  544. created() {
  545. this.getData();
  546. }
  547. }
  548. </script>
  549. <style >
  550. .el-textarea__inner {
  551. padding: 5px 5px;
  552. }
  553. </style>