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.

681 lines
22 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- 条件查询 -->
  4. <el-form :inline="true" label-position="top" :model="searchData">
  5. <el-form-item :label="'BU'">
  6. <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 80px">
  7. <el-option
  8. v-for = "i in userBuList"
  9. :key = "i.buNo"
  10. :label = "i.buDesc"
  11. :value = "i.buDesc">
  12. </el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item :label="'检验等级编码'">
  16. <el-input v-model="searchData.samplingLevelNo" clearable style="width: 120px"></el-input>
  17. </el-form-item>
  18. <el-form-item :label="'检验等级描述'">
  19. <el-input v-model="searchData.samplingLevelDesc" clearable style="width: 200px"></el-input>
  20. </el-form-item>
  21. <el-form-item :label="'是否可用'">
  22. <el-select v-model="searchData.samplingLevelActive" style="width: 80px">
  23. <el-option label="全部" value=""></el-option>
  24. <el-option label="是" value="Y"></el-option>
  25. <el-option label="否" value="N"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item :label="' '">
  29. <!-- <el-button @click="doEmpty()">清空</el-button>-->
  30. <el-button v-if="!authSearch" type="primary" @click="getDataList()">查询</el-button>
  31. <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
  32. <download-excel
  33. :fields="fields()"
  34. :data="exportData"
  35. type="xls"
  36. :name="exportName"
  37. :header="exportHeader"
  38. :footer="exportFooter"
  39. :fetch="createExportData"
  40. :before-generate="startDownload"
  41. :before-finish="finishDownload"
  42. worksheet="导出信息"
  43. class="el-button el-button--primary el-button--medium">
  44. {{ "导出" }}
  45. </download-excel>
  46. </el-form-item>
  47. </el-form>
  48. <!-- 展示列表 -->
  49. <el-table
  50. :height="height"
  51. :data="dataList"
  52. border
  53. v-loading="dataListLoading"
  54. style="width: 100%;">
  55. <el-table-column
  56. v-for="(item,index) in columnList" :key="index"
  57. :sortable="item.columnSortable"
  58. :prop="item.columnProp"
  59. :header-align="item.headerAlign"
  60. :show-overflow-tooltip="item.showOverflowTooltip"
  61. :align="item.align"
  62. :fixed="item.fixed===''?false:item.fixed"
  63. :min-width="item.columnWidth"
  64. :label="item.columnLabel">
  65. <template slot-scope="scope">
  66. <span v-if="!item.columnHidden">
  67. <span v-if="columnsProp.includes(item.columnProp)">{{ scope.row[`${item.columnProp}Desc`] }}</span>
  68. <span v-else>
  69. {{ scope.row[item.columnProp] }}
  70. </span>
  71. </span>
  72. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. fixed="right"
  77. header-align="center"
  78. align="center"
  79. width="160"
  80. label="操作">
  81. <template slot-scope="scope">
  82. <a v-if="!authUpdate" type="text" size="small" @click="updateModal(scope.row)">修改</a>
  83. <a v-if="!authDelete" type="text" size="small" @click="deleteModal(scope.row)">删除</a>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <!-- 新增和修改 -->
  88. <el-dialog title="检验方法" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="500px">
  89. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  90. <el-form-item label="BU" prop="bu" :rules="rules.bu">
  91. <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 456px">
  92. <el-option
  93. v-for = "i in userBuList"
  94. :key = "i.buNo"
  95. :label = "i.sitename"
  96. :value = "i.buNo">
  97. <span style="float: left;width: 100px">{{ i.sitename }}</span>
  98. <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
  99. {{ i.buDesc }}
  100. </span>
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. </el-form>
  105. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  106. <el-form-item label="检验等级描述:" prop="samplingLevelDesc" :rules="rules.samplingLevelDescType">
  107. <el-input v-model="modalData.samplingLevelDesc" style="width: 221px"></el-input>
  108. </el-form-item>
  109. <el-form-item :label="'是否可用'" prop="samplingLevelActive" :rules="rules.samplingLevelActiveType">
  110. <el-select filterable v-model="modalData.samplingLevelActive" style="width: 221px">
  111. <el-option label="是" value="Y"></el-option>
  112. <el-option label="否" value="N"></el-option>
  113. </el-select>
  114. </el-form-item>
  115. </el-form>
  116. <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
  117. <el-form-item label="备注说明:">
  118. <el-input v-model="modalData.samplingLevelRemark" style="width: 456px"></el-input>
  119. </el-form-item>
  120. </el-form>
  121. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  122. <el-button type="primary" @click="saveData()">保存</el-button>
  123. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  124. </el-footer>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import {
  130. samplingLevelSearch, // 查询检验等级
  131. samplingLevelSave, // 新增检验等级
  132. samplingLevelUpdate, // 修改检验等级
  133. samplingLevelDelete, // 删除检验等级
  134. getSiteAndBuByUserName
  135. } from "@/api/qc/qc.js"
  136. import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  137. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  138. export default {
  139. data () {
  140. return {
  141. columnsProp:['createBy','samplingLevelActive','updateBy'],
  142. // 是否收藏
  143. favorite: false,
  144. // 导出 start
  145. exportData: [],
  146. exportName: "样本量" + this.dayjs().format('YYYYMMDDHHmmss'),
  147. exportHeader: ["样本量"],
  148. exportFooter: [],
  149. exportList: [],
  150. // 导出 end
  151. searchData: {
  152. site: '',
  153. userName: this.$store.state.user.name,
  154. samplingLevelNo: '',
  155. samplingLevelDesc: '',
  156. samplingLevelActive: '',
  157. buDesc: '',
  158. page: 1,
  159. limit: 10,
  160. },
  161. pageIndex: 1,
  162. pageSize: 20,
  163. totalPage: 0,
  164. height: 200,
  165. dataList: [],
  166. dataListLoading: false,
  167. modalFlag: false,
  168. modalDisableFlag: false,
  169. modalData: {
  170. flag: '',
  171. site: '',
  172. bu: '',
  173. samplingLevelNo: '',
  174. samplingLevelDesc: '',
  175. samplingLevelActive: '',
  176. samplingLevelRemark: '',
  177. createBy: this.$store.state.user.name,
  178. updateBy: this.$store.state.user.name
  179. },
  180. // 标头展示
  181. columnList: [
  182. {
  183. userId: this.$store.state.user.name,
  184. functionId: 301011,
  185. serialNumber: '301011TableBuDesc',
  186. tableId: "301011Table",
  187. tableName: "检验水平表",
  188. columnProp: 'buDesc',
  189. headerAlign: 'center',
  190. align: "center",
  191. columnLabel: 'BU',
  192. columnHidden: false,
  193. columnImage: false,
  194. columnSortable: false,
  195. sortLv: 0,
  196. status: true,
  197. fixed: '',
  198. columnWidth: 100,
  199. },
  200. {
  201. userId: this.$store.state.user.name,
  202. functionId: 301011,
  203. serialNumber: '301011TableSamplingLevelNo',
  204. tableId: "301011Table",
  205. tableName: "检验水平表",
  206. columnProp: 'samplingLevelNo',
  207. headerAlign: 'center',
  208. align: "center",
  209. columnLabel: '检验等级编码',
  210. columnHidden: false,
  211. columnImage: false,
  212. columnSortable: false,
  213. sortLv: 0,
  214. status: true,
  215. fixed: '',
  216. columnWidth: 120,
  217. },
  218. {
  219. userId: this.$store.state.user.name,
  220. functionId: 301011,
  221. serialNumber: '301011TableSamplingLevelDesc',
  222. tableId: "301011Table",
  223. tableName: "检验水平表",
  224. columnProp: 'samplingLevelDesc',
  225. headerAlign: 'center',
  226. align: "left",
  227. columnLabel: '检验等级描述',
  228. columnHidden: false,
  229. columnImage: false,
  230. columnSortable: false,
  231. sortLv: 0,
  232. status: true,
  233. fixed: '',
  234. columnWidth: 200,
  235. },
  236. {
  237. userId: this.$store.state.user.name,
  238. functionId: 301011,
  239. serialNumber: '301011TableSamplingLevelRemark',
  240. tableId: "301011Table",
  241. tableName: "检验水平表",
  242. columnProp: 'samplingLevelRemark',
  243. headerAlign: 'center',
  244. align: "left",
  245. columnLabel: '备注说明',
  246. columnHidden: false,
  247. columnImage: false,
  248. columnSortable: false,
  249. sortLv: 0,
  250. status: true,
  251. fixed: '',
  252. columnWidth: 200,
  253. },
  254. {
  255. userId: this.$store.state.user.name,
  256. functionId: 301011,
  257. serialNumber: '301011TableSamplingLevelActive',
  258. tableId: "301011Table",
  259. tableName: "检验水平表",
  260. columnProp: 'samplingLevelActive',
  261. headerAlign: 'center',
  262. align: "center",
  263. columnLabel: '是否可用',
  264. columnHidden: false,
  265. columnImage: false,
  266. columnSortable: false,
  267. sortLv: 0,
  268. status: true,
  269. fixed: '',
  270. columnWidth: 100,
  271. },
  272. {
  273. userId: this.$store.state.user.name,
  274. functionId: 301011,
  275. serialNumber: '301011TableCreateDate',
  276. tableId: "301011Table",
  277. tableName: "检验水平表",
  278. columnProp: 'createDate',
  279. headerAlign: 'center',
  280. align: "center",
  281. columnLabel: '创建时间',
  282. columnHidden: false,
  283. columnImage: false,
  284. columnSortable: false,
  285. sortLv: 0,
  286. status: true,
  287. fixed: '',
  288. columnWidth: 170,
  289. },
  290. {
  291. userId: this.$store.state.user.name,
  292. functionId: 301011,
  293. serialNumber: '301011TableCreateBy',
  294. tableId: "301011Table",
  295. tableName: "检验水平表",
  296. columnProp: 'createBy',
  297. headerAlign: 'center',
  298. align: "center",
  299. columnLabel: '创建人',
  300. columnHidden: false,
  301. columnImage: false,
  302. columnSortable: false,
  303. sortLv: 0,
  304. status: true,
  305. fixed: '',
  306. columnWidth: 100,
  307. },
  308. {
  309. userId: this.$store.state.user.name,
  310. functionId: 301011,
  311. serialNumber: '301011TableUpdateDate',
  312. tableId: "301011Table",
  313. tableName: "检验水平表",
  314. columnProp: 'updateDate',
  315. headerAlign: 'center',
  316. align: "center",
  317. columnLabel: '更新时间',
  318. columnHidden: false,
  319. columnImage: false,
  320. columnSortable: false,
  321. sortLv: 0,
  322. status: true,
  323. fixed: '',
  324. columnWidth: 170,
  325. },
  326. {
  327. userId: this.$store.state.user.name,
  328. functionId: 301011,
  329. serialNumber: '301011TableUpdateBy',
  330. tableId: "301011Table",
  331. tableName: "检验水平表",
  332. columnProp: 'updateBy',
  333. headerAlign: 'center',
  334. align: "center",
  335. columnLabel: '更新人',
  336. columnHidden: false,
  337. columnImage: false,
  338. columnSortable: false,
  339. sortLv: 0,
  340. status: true,
  341. fixed: '',
  342. columnWidth: 100,
  343. },
  344. ],
  345. rules: {
  346. samplingLevelDescType:[
  347. {
  348. required: true,
  349. message: ' ',
  350. trigger: ['blur','change']
  351. }
  352. ],
  353. samplingLevelActiveType:[
  354. {
  355. required: true,
  356. message: ' ',
  357. trigger: ['blur','change']
  358. }
  359. ],
  360. bu:[
  361. {
  362. required: true,
  363. message: ' ',
  364. trigger: ['blur','change']
  365. }
  366. ]
  367. },
  368. userBuList: [],
  369. authSearch: false,
  370. authSave: false,
  371. authUpdate: false,
  372. authDelete: false,
  373. menuId: this.$route.meta.menuId,
  374. }
  375. },
  376. mounted () {
  377. this.$nextTick(() => {
  378. this.height = window.innerHeight - 150
  379. })
  380. },
  381. created () {
  382. // 按钮控制
  383. this.getButtonAuthData()
  384. // 获取用户的 site 和 bu
  385. this.getSiteAndBuByUserName()
  386. // 校验用户是否收藏
  387. this.favoriteIsOk()
  388. // 动态列
  389. this.getTableUserColumn(this.$route.meta.menuId+'table',1)
  390. if (!this.authSearch) {
  391. // 获取数据列表
  392. this.getDataList()
  393. }
  394. },
  395. methods: {
  396. // 获取用户的bu
  397. getSiteAndBuByUserName () {
  398. let tempData = {
  399. username: this.$store.state.user.name,
  400. }
  401. getSiteAndBuByUserName(tempData).then(({data}) => {
  402. if (data.code === 0) {
  403. this.userBuList = data.rows
  404. }
  405. })
  406. },
  407. // 查询获取数据列表
  408. getDataList () {
  409. this.searchData.limit = this.pageSize
  410. this.searchData.page = this.pageIndex
  411. samplingLevelSearch(this.searchData).then(({data}) => {
  412. this.dataList = data.page.list
  413. this.pageIndex = data.page.currPage
  414. this.pageSize = data.page.pageSize
  415. this.totalPage = data.page.totalCount
  416. })
  417. },
  418. // 新增按钮
  419. addModal () {
  420. this.modalData = {
  421. flag: '1',
  422. bu: this.userBuList[0].buNo,
  423. site: '',
  424. samplingLevelNo: '',
  425. samplingLevelDesc: '',
  426. samplingLevelActive: 'Y',
  427. samplingLevelRemark: '',
  428. createBy: this.$store.state.user.name,
  429. updateBy: this.$store.state.user.name
  430. }
  431. this.modalDisableFlag = false
  432. this.modalFlag = true
  433. },
  434. // 修改按钮
  435. updateModal (row) {
  436. this.modalData = {
  437. flag: '2',
  438. bu: row.site + '_' + row.buNo,
  439. site: row.site,
  440. samplingLevelNo: row.samplingLevelNo,
  441. samplingLevelDesc: row.samplingLevelDesc,
  442. samplingLevelActive: row.samplingLevelActive,
  443. samplingLevelRemark: row.samplingLevelRemark,
  444. createBy: this.$store.state.user.name,
  445. updateBy: this.$store.state.user.name
  446. }
  447. this.modalDisableFlag = true
  448. this.modalFlag = true
  449. },
  450. // 删除方法
  451. deleteModal (row) {
  452. this.$confirm(`是否删除这个检验等级?`, '提示', {
  453. confirmButtonText: '确定',
  454. cancelButtonText: '取消',
  455. type: 'warning'
  456. }).then(() => {
  457. samplingLevelDelete(row).then(({data}) => {
  458. if (data && data.code === 0) {
  459. this.getDataList()
  460. this.$message({
  461. message: '操作成功',
  462. type: 'success',
  463. duration: 1500,
  464. onClose: () => {}
  465. })
  466. } else {
  467. this.$alert(data.msg, '错误', {
  468. confirmButtonText: '确定'
  469. })
  470. }
  471. })
  472. }).catch(() => {
  473. })
  474. },
  475. // 新增/修改方法
  476. saveData () {
  477. if (this.modalData.bu === '' || this.modalData.bu == null) {
  478. this.$message.warning('请选择BU!')
  479. return
  480. }
  481. if (this.modalData.samplingLevelDesc === '' || this.modalData.samplingLevelDesc == null) {
  482. this.$message.warning('请输入检验等级描述!')
  483. return
  484. }
  485. if (this.modalData.samplingLevelActive === '' || this.modalData.samplingLevelActive == null) {
  486. this.$message.warning('请选择是否在用!')
  487. return
  488. }
  489. if (this.modalData.flag === '1') { // 新增
  490. samplingLevelSave(this.modalData).then(({data}) => {
  491. if (data && data.code === 0) {
  492. this.getDataList()
  493. this.modalFlag = false
  494. this.$message({
  495. message: '操作成功',
  496. type: 'success',
  497. duration: 1500,
  498. onClose: () => {}
  499. })
  500. } else {
  501. this.$alert(data.msg, '错误', {
  502. confirmButtonText: '确定'
  503. })
  504. }
  505. })
  506. } else { // 修改
  507. samplingLevelUpdate(this.modalData).then(({data}) => {
  508. if (data && data.code === 0) {
  509. this.getDataList()
  510. this.modalFlag = false
  511. this.$message({
  512. message: '操作成功',
  513. type: 'success',
  514. duration: 1500,
  515. onClose: () => {}
  516. })
  517. } else {
  518. this.$alert(data.msg, '错误', {
  519. confirmButtonText: '确定'
  520. })
  521. }
  522. })
  523. }
  524. },
  525. // 校验用户是否收藏
  526. favoriteIsOk () {
  527. let userFavorite = {
  528. userId: this.$store.state.user.id,
  529. languageCode: this.$i18n.locale
  530. }
  531. userFavoriteList(userFavorite).then(({data}) => {
  532. for (let i = 0; i < data.list.length; i++) {
  533. if (this.$route.meta.menuId === data.list[i].menuId) {
  534. this.favorite = true
  535. }
  536. }
  537. })
  538. },
  539. // 收藏 OR 取消收藏
  540. favoriteFunction () {
  541. let userFavorite = {
  542. userId: this.$store.state.user.id,
  543. functionId: this.$route.meta.menuId,
  544. }
  545. if (this.favorite) {
  546. removeUserFavorite(userFavorite).then(({data}) => {
  547. this.$message.success(data.msg)
  548. this.favorite = false
  549. })
  550. } else {
  551. // 收藏
  552. saveUserFavorite(userFavorite).then(({data}) => {
  553. this.$message.success(data.msg)
  554. this.favorite = true
  555. })
  556. }
  557. },
  558. // 导出excel
  559. async createExportData () {
  560. this.searchData.limit = -1
  561. this.searchData.page = 1
  562. await samplingLevelSearch(this.searchData).then(({data}) => {
  563. this.exportList = data.rows
  564. })
  565. return this.exportList
  566. },
  567. startDownload() {},
  568. finishDownload() {},
  569. fields () {
  570. let json = "{"
  571. this.columnList.forEach((item, index) => {
  572. if (index == this.columnList.length - 1) {
  573. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  574. } else {
  575. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  576. }
  577. })
  578. json += "}"
  579. let s = eval("(" + json + ")")
  580. return s
  581. },
  582. // 动态列开始 获取 用户保存的 格式列
  583. async getTableUserColumn (tableId, columnId) {
  584. let queryTableUser = {
  585. userId: this.$store.state.user.name,
  586. functionId: this.$route.meta.menuId,
  587. tableId: tableId,
  588. status: true,
  589. languageCode: this.$i18n.locale
  590. }
  591. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  592. if (data.rows.length > 0) {
  593. //this.columnList1 = []
  594. switch (columnId) {
  595. case 1:
  596. this.columnList = data.rows
  597. break;
  598. // case 2:
  599. // this.columnDetailList = data.rows
  600. // break;
  601. // case 3:
  602. // this.columnList2 = data.rows
  603. // break;
  604. // case 4:
  605. // this.columnList3 = data.rows
  606. // break;
  607. }
  608. } else {
  609. this.getColumnList(tableId, columnId)
  610. }
  611. })
  612. },
  613. // 获取 tableDefault 列
  614. async getColumnList (tableId, columnId) {
  615. let queryTable= {
  616. functionId: this.$route.meta.menuId,
  617. tableId: tableId,
  618. languageCode: this.$i18n.locale
  619. }
  620. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  621. if (!data.rows.length == 0) {
  622. switch (columnId) {
  623. case 1:
  624. this.columnList = data.rows
  625. break;
  626. // case 2:
  627. // this.columnDetailList = data.rows
  628. // break;
  629. // case 3:
  630. // this.columnList2 = data.rows
  631. // break;
  632. // case 4:
  633. // this.columnList3 = data.rows
  634. // break;
  635. }
  636. } else {
  637. // this.showDefault = true.
  638. }
  639. })
  640. },
  641. //获取按钮的权限数据
  642. getButtonAuthData () {
  643. let searchFlag = this.isAuth(this.menuId+":search")
  644. let saveFlag = this.isAuth(this.menuId+":save")
  645. let updateFlag = this.isAuth(this.menuId+":update")
  646. let deleteFlag = this.isAuth(this.menuId+":delete")
  647. //处理页面的权限数据
  648. this.authSearch = !searchFlag
  649. this.authSave = !saveFlag
  650. this.authUpdate = !updateFlag
  651. this.authDelete = !deleteFlag
  652. },
  653. }
  654. }
  655. </script>
  656. <style scoped>
  657. .el-table /deep/ .cell{
  658. height: auto;
  659. line-height: 1.5;
  660. }
  661. </style>