enrolled.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="dialogVisible"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. append-to-body
  8. width="60%"
  9. class="dialog enrolled-dialog"
  10. top="6vh"
  11. @close="closeDialog"
  12. @open="getShiftHandoverData"
  13. >
  14. <el-form
  15. ref="ruleForm"
  16. :model="ruleForm"
  17. :rules="rules"
  18. label-width="110px"
  19. class="demo-ruleForm"
  20. >
  21. <!-- 主表选择 -->
  22. <el-row :gutter="30">
  23. <el-col :span="8">
  24. <el-form-item label="部门" prop="deng_ji_bu_men_">
  25. <ibps-user-selector
  26. v-model="ruleForm.deng_ji_bu_men_"
  27. type="position"
  28. readonly-text="text"
  29. :disabled="!editPermissions"
  30. :multiple="false"
  31. /> </el-form-item
  32. ></el-col>
  33. <el-col :span="8">
  34. <el-form-item label="岗位" prop="gang_wei_">
  35. <!-- <el-input v-model="ruleForm.gang_wei_" type="text" :disabled="!editPermissions" /> -->
  36. <el-select
  37. v-model="ruleForm.gang_wei_"
  38. placeholder="请选择"
  39. size="mini"
  40. style="width: 100%"
  41. :disabled="!editPermissions"
  42. >
  43. <el-option
  44. v-for="item in filterData"
  45. :key="item.positionId"
  46. :label="item.positionName"
  47. :value="item.positionName"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <!-- <ibps-link-data
  52. v-model="ruleForm.gang_wei_"
  53. style="width:80%"
  54. size="mini"
  55. template-key="jcgwxz"
  56. :multiple="false"
  57. :temp-search="true"
  58. /> -->
  59. </el-col>
  60. <el-col :span="8">
  61. <el-form-item label="日期" prop="deng_ji_shi_jian_">
  62. <el-date-picker
  63. v-model="ruleForm.deng_ji_shi_jian_"
  64. type="date"
  65. placeholder="选择日期"
  66. style="width: 100%"
  67. :disabled="!editPermissions"
  68. /> </el-form-item
  69. ></el-col>
  70. </el-row>
  71. <el-form-item label=" 班次" prop="ban_ci_">
  72. <span v-if="editPermissions">早班</span>
  73. <span v-else>{{
  74. parentData.zhuang_tai_ === '已早交班'
  75. ? '午班'
  76. : parentData.zhuang_tai_ === '已午交班'
  77. ? '晚班'
  78. : ''
  79. }}</span>
  80. <!-- <span v-else>{{ ruleForm.ban_ci_ }}</span> -->
  81. </el-form-item>
  82. <el-row :gutter="30">
  83. <el-col :span="8"
  84. ><div class="grid-content bg-purple-dark">
  85. <el-form-item label="交班标本(例)" prop="jiao_ban_biao_ben">
  86. <el-input
  87. v-model.number="ruleForm.jiao_ban_biao_ben"
  88. style="width: 100%"
  89. /> </el-form-item></div
  90. ></el-col>
  91. <el-col :span="8"
  92. ><div class="grid-content bg-purple-dark">
  93. <el-form-item label="未处理标本(例)" prop="wei_chu_li_biao_b">
  94. <el-input
  95. v-model.number="ruleForm.wei_chu_li_biao_b"
  96. style="width: 100%"
  97. /> </el-form-item></div
  98. ></el-col>
  99. <el-col :span="8"
  100. ><div class="grid-content bg-purple-dark">
  101. <el-form-item label="未发报告(例)" prop="wei_fa_bao_gao_">
  102. <el-input
  103. v-model.number="ruleForm.wei_fa_bao_gao_"
  104. style="width: 100%"
  105. /> </el-form-item></div
  106. ></el-col>
  107. </el-row>
  108. <el-row :gutter="30">
  109. <el-col :span="8">
  110. <div class="grid-content bg-purple-dark">
  111. <el-form-item label="是否查漏" prop="shi_fou_cha_lou_" required>
  112. <el-radio-group v-model="ruleForm.shi_fou_cha_lou_">
  113. <el-radio label="是" />
  114. <el-radio label="否" />
  115. </el-radio-group>
  116. </el-form-item>
  117. </div>
  118. </el-col>
  119. <el-col v-show="ruleForm.shi_fou_cha_lou_ == '是'" :span="8"
  120. ><div class="grid-content bg-purple-dark">
  121. <el-form-item label="漏发漏检(例)" prop="lou_fa_lou_jian_">
  122. <el-input
  123. v-model.number="ruleForm.lou_fa_lou_jian_"
  124. style="width: 100%"
  125. /> </el-form-item></div
  126. ></el-col>
  127. </el-row>
  128. <el-form-item label="其他异常情况" prop="qi_ta_qing_kuang_">
  129. <el-input v-model="ruleForm.qi_ta_qing_kuang_" type="textarea" />
  130. </el-form-item>
  131. <el-row :gutter="30">
  132. <el-col :span="8">
  133. <div class="grid-content bg-purple-dark">
  134. <el-form-item label="接班人:" prop="jie_ban_ren_">
  135. <ibps-user-selector
  136. v-model="ruleForm.jie_ban_ren_"
  137. type="user"
  138. readonly-text="text"
  139. :disabled="false"
  140. :multiple="true"
  141. :temp-search="true"
  142. :filter="filter"
  143. filterable
  144. />
  145. </el-form-item>
  146. </div>
  147. </el-col>
  148. <el-col :span="8">
  149. <div class="grid-content bg-purple-dark">
  150. <el-form-item label="交班人:" prop="jiao_ban_ren_">
  151. <!-- const roleList = ['xtgljs']
  152. const { isSuper, role, userId, userList = [] } = this.$store.getters || {}
  153. this.userId = userId
  154. this.userList = userList
  155. this.hasRole = isSuper || role.some(r => roleList.includes(r.alias)) -->
  156. <ibps-user-selector
  157. v-model="ruleForm.jiao_ban_ren_"
  158. type="user"
  159. readonly-text="text"
  160. :disabled="!hasRole"
  161. :multiple="false"
  162. :filter="filter"
  163. filterable
  164. />
  165. </el-form-item>
  166. </div>
  167. </el-col>
  168. </el-row>
  169. <!-- <el-form-item class="footer-btn">
  170. <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
  171. <el-button @click="dialogVisible=false">取消</el-button>
  172. </el-form-item> -->
  173. </el-form>
  174. <span slot="footer" class="dialog-footer">
  175. <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
  176. <el-button @click="dialogVisible = false">取消</el-button>
  177. </span>
  178. </el-dialog>
  179. </template>
  180. <script>
  181. import log from '@/plugins/log'
  182. import ibpsUserSelector from '@/business/platform/org/selector'
  183. import IbpsLinkData from '@/business/platform/data/templaterender/link-data'
  184. import getDate from '@/utils/common'
  185. import { getSetting } from '@/utils/query'
  186. export default {
  187. components: {
  188. ibpsUserSelector,
  189. IbpsLinkData,
  190. IbpsCustomDialog: () =>
  191. import('@/business/platform/data/templaterender/custom-dialog')
  192. },
  193. props: {
  194. visible: {
  195. type: Boolean,
  196. default: false
  197. },
  198. parentData: {
  199. type: [Object, Array],
  200. default: () => {}
  201. }
  202. },
  203. data() {
  204. const { userId, setting } = this.$store.getters || {}
  205. return {
  206. filter: [
  207. {
  208. descVal: '2',
  209. includeSub: true,
  210. old: 'position',
  211. partyId: this.$store.getters.userInfo.employee.positions,
  212. partyName: '',
  213. scriptContent: '',
  214. type: 'user',
  215. userType: 'position'
  216. }
  217. ],
  218. enrolledSum: false,
  219. userId: userId,
  220. editPermissions: false,
  221. isDisabled: false,
  222. title: '交接班',
  223. dialogVisible: this.visible,
  224. ruleForm: {
  225. deng_ji_bu_men_: '',
  226. gang_wei_: '',
  227. deng_ji_shi_jian_: this.dataShow(new Date()),
  228. shi_jian_: '',
  229. ban_ci_: '',
  230. jiao_ban_biao_ben: 0,
  231. wei_chu_li_biao_b: 0,
  232. wei_fa_bao_gao_: 0,
  233. shi_fou_cha_lou_: '是',
  234. lou_fa_lou_jian_: 0,
  235. qi_ta_qing_kuang_: '',
  236. jie_ban_ren_: '',
  237. jiao_ban_ren_: ''
  238. },
  239. rules: {
  240. ban_ci_: [{ required: false, message: this.$t('validate.required') }],
  241. deng_ji_bu_men_: [
  242. { required: true, message: this.$t('validate.required') }
  243. ],
  244. gang_wei_: [{ required: true, message: this.$t('validate.required') }],
  245. deng_ji_shi_jian_: [
  246. { required: true, message: this.$t('validate.required') }
  247. ],
  248. jiao_ban_biao_ben: [
  249. { required: true, message: this.$t('validate.required') },
  250. {
  251. validator: (rule, value, callback) => {
  252. if (value === '') {
  253. callback()
  254. } else if (Number.isInteger(value) && value >= 0) {
  255. callback()
  256. } else {
  257. callback(new Error(this.$t('请输入数字')))
  258. }
  259. },
  260. trigger: ['change', 'blur']
  261. }
  262. ],
  263. wei_chu_li_biao_b: [
  264. { required: true, message: this.$t('validate.required') },
  265. {
  266. validator: (rule, value, callback) => {
  267. if (value === '') {
  268. callback()
  269. } else if (Number.isInteger(value) && value >= 0) {
  270. callback()
  271. } else {
  272. callback(new Error(this.$t('请输入数字')))
  273. }
  274. },
  275. trigger: ['change', 'blur']
  276. }
  277. ],
  278. wei_fa_bao_gao_: [
  279. { required: true, message: this.$t('validate.required') },
  280. {
  281. validator: (rule, value, callback) => {
  282. if (value === '') {
  283. callback()
  284. } else if (Number.isInteger(value) && value >= 0) {
  285. callback()
  286. } else {
  287. callback(new Error(this.$t('请输入数字')))
  288. }
  289. },
  290. trigger: ['change', 'blur']
  291. }
  292. ],
  293. shi_fou_cha_lou_: [
  294. { required: true, message: this.$t('validate.required') }
  295. ],
  296. lou_fa_lou_jian_: [
  297. { required: true, message: this.$t('validate.required') },
  298. {
  299. validator: (rule, value, callback) => {
  300. if (value === '') {
  301. callback()
  302. } else if (Number.isInteger(value) && value >= 0) {
  303. callback()
  304. } else {
  305. callback(new Error(this.$t('请输入数字')))
  306. }
  307. },
  308. trigger: ['change', 'blur']
  309. }
  310. ],
  311. jie_ban_ren_: [
  312. { required: true, message: this.$t('validate.required') }
  313. ],
  314. jiao_ban_ren_: [
  315. { required: true, message: this.$t('validate.required') }
  316. ]
  317. },
  318. jianCeGangWeiList: [],
  319. filterData: [],
  320. masterReport: ['已早交班', '已午交班', '已晚交班', '已完成'],
  321. subReport: ['早班', '午班', '晚班'],
  322. config: setting?.postJob?.allocation || false
  323. }
  324. },
  325. computed: {
  326. hasRole() {
  327. const roleList = ['xtgljs']
  328. const { isSuper, role } = this.$store.getters || {}
  329. return isSuper || role.some((r) => roleList.includes(r.alias))
  330. }
  331. },
  332. watch: {
  333. visible: {
  334. handler: function (val, oldVal) {
  335. this.dialogVisible = this.visible
  336. }
  337. // immediate: true
  338. },
  339. 'ruleForm.deng_ji_bu_men_': {
  340. handler(val) {
  341. console.log(val)
  342. this.filterData = this.jianCeGangWeiList.filter((i) => i.dept === val)
  343. },
  344. deep: true
  345. },
  346. 'ruleForm.wei_chu_li_biao_b': {
  347. handler(val) {
  348. if (this.enrolledSum) {
  349. this.ruleForm.jiao_ban_biao_ben = this.ruleForm.wei_fa_bao_gao_ + val
  350. }
  351. },
  352. deep: true
  353. },
  354. 'ruleForm.wei_fa_bao_gao_': {
  355. handler(val) {
  356. if (this.enrolledSum) {
  357. this.ruleForm.jiao_ban_biao_ben =
  358. this.ruleForm.wei_chu_li_biao_b + val
  359. }
  360. },
  361. deep: true
  362. }
  363. },
  364. mounted() {
  365. this.loadSelectorData()
  366. },
  367. async created() {
  368. const res = await getSetting()
  369. const enrolledSum = res.enrolledSum || false
  370. this.enrolledSum = enrolledSum
  371. if (this.parentData) {
  372. if (this.parentData.id_) {
  373. this.ruleForm.deng_ji_bu_men_ = this.parentData.deng_ji_bu_men_
  374. this.ruleForm.deng_ji_shi_jian_ = this.parentData.deng_ji_shi_jian_
  375. this.ruleForm.gang_wei_ = this.parentData.gang_wei_
  376. this.ruleForm.jiao_ban_ren_ = this.userId
  377. this.editPermissions = false
  378. // this.ruleForm.ban_ci_ = this.parentData.zhuang_tai_ === '已早交班' ? '早班' : this.parentData.zhuang_tai_ === '已午交班' ? '午班' : '晚班'
  379. } else {
  380. this.ruleForm.jiao_ban_ren_ = this.userId
  381. this.editPermissions = true
  382. }
  383. } else {
  384. this.ruleForm.jiao_ban_ren_ = this.userId
  385. this.editPermissions = true
  386. }
  387. },
  388. methods: {
  389. // 修改
  390. loadSelectorData() {
  391. const { first, second } = this.$store.getters.level || {}
  392. // const sql = `select * from t_sbwhgwpzb where di_dian_='${second || first}'`
  393. this.$common
  394. .request('query', {
  395. key: this.config ? 'gwzzzha' : 'getPositionList',
  396. params: [second || first]
  397. })
  398. .then((res) => {
  399. const { data = [] } = res.variables || {}
  400. this.jianCeGangWeiList = data
  401. })
  402. },
  403. closeDialog() {
  404. this.$emit('close', false)
  405. },
  406. getShiftHandoverData() {
  407. this.submitForm()
  408. },
  409. dataShow(times) {
  410. const timeDate = new Date(times)
  411. const year = timeDate.getFullYear()
  412. const month = ('0' + (timeDate.getMonth() + 1)).slice(-2) // 月份从0开始,所以加1
  413. const day = ('0' + timeDate.getDate()).slice(-2)
  414. return `${year}-${month}-${day}`
  415. },
  416. addDatebase(dataBaseName, data) {
  417. const params = {
  418. tableName: dataBaseName,
  419. paramWhere: [data]
  420. }
  421. return this.$common
  422. .request('add', params)
  423. .then((res) => {
  424. return res
  425. })
  426. .catch((err) => {
  427. console.log(err)
  428. throw err
  429. })
  430. },
  431. submitForm(formName) {
  432. const masterTableData = {
  433. deng_ji_bu_men_: this.ruleForm.deng_ji_bu_men_,
  434. gang_wei_: this.ruleForm.gang_wei_,
  435. deng_ji_shi_jian_: this.dataShow(this.ruleForm.deng_ji_shi_jian_),
  436. zhuang_tai_: this.masterReport[0],
  437. jie_ban_ren_: this.ruleForm.jie_ban_ren_
  438. }
  439. const subtablesData = {
  440. parent_id_: '',
  441. ban_ci_: this.ruleForm.ban_ci_,
  442. jiao_ban_biao_ben: this.ruleForm.jiao_ban_biao_ben,
  443. jie_ban_ren_: this.ruleForm.jie_ban_ren_,
  444. jiao_ban_ren_: this.ruleForm.jiao_ban_ren_,
  445. wei_chu_li_biao_b: this.ruleForm.wei_chu_li_biao_b,
  446. wei_fa_bao_gao_: this.ruleForm.wei_fa_bao_gao_,
  447. shi_fou_cha_lou_: this.ruleForm.shi_fou_cha_lou_,
  448. lou_fa_lou_jian_: this.ruleForm.lou_fa_lou_jian_,
  449. qi_ta_qing_kuang_: this.ruleForm.qi_ta_qing_kuang_
  450. }
  451. this.$refs[formName]?.validate((valid) => {
  452. if (valid) {
  453. if (this.editPermissions) {
  454. // 主表和子表一起添加一条数据
  455. this.addDatebase('t_jjbdjb', masterTableData).then(() => {
  456. // const sql = 'select * from t_jjbdjb order by create_time_ desc limit 1'
  457. subtablesData.parent_id_ = ''
  458. this.$common
  459. .request('query', {
  460. key: 'getJjbLatestRecord',
  461. params: [null]
  462. })
  463. .then((res) => {
  464. subtablesData.parent_id_ = res.variables.data[0].id_
  465. subtablesData.ban_ci_ = this.subReport[0]
  466. if (subtablesData.parent_id_) {
  467. this.addDatebase('t_jjbjlb', subtablesData).then(() => {
  468. this.dialogVisible = false
  469. this.remind(subtablesData.jie_ban_ren_.split(','))
  470. })
  471. }
  472. })
  473. .catch((err) => {
  474. console.log(err)
  475. })
  476. })
  477. } else {
  478. // 子表添加一条数据
  479. // const sql = 'select* from t_jjbjlb WHERE parent_id_=' + this.parentData.id_
  480. this.$common
  481. .request('query', {
  482. key: 'getJjbByParentId',
  483. params: [this.parentData.id_]
  484. })
  485. .then((res) => {
  486. const count = res.variables.data.length
  487. subtablesData.parent_id_ = this.parentData.id_
  488. switch (count) {
  489. case 1:
  490. subtablesData.ban_ci_ = this.subReport[count]
  491. console.log(this.subReport[count])
  492. this.addDatebase('t_jjbjlb', subtablesData).then(() => {
  493. const params = {
  494. zhuang_tai_: this.masterReport[count],
  495. jie_ban_ren_: subtablesData.jie_ban_ren_
  496. }
  497. this.updataMaster('t_jjbdjb', this.parentData.id_, params)
  498. this.dialogVisible = false
  499. this.remind(subtablesData.jie_ban_ren_.split(','))
  500. })
  501. break
  502. case 2:
  503. subtablesData.ban_ci_ = this.subReport[count]
  504. this.addDatebase('t_jjbjlb', subtablesData).then(() => {
  505. this.createSnapshoot(this.parentData.id_).then((res) => {
  506. const params = {
  507. zhuang_tai_: this.masterReport[count + 1],
  508. jie_ban_ren_: subtablesData.jie_ban_ren_,
  509. kuai_zhao_: res
  510. }
  511. this.updataMaster(
  512. 't_jjbdjb',
  513. this.parentData.id_,
  514. params
  515. )
  516. this.dialogVisible = false
  517. })
  518. })
  519. break
  520. default:
  521. }
  522. })
  523. }
  524. } else {
  525. return false
  526. }
  527. })
  528. },
  529. updataMaster(masterName, id_, params) {
  530. return new Promise((resolve, reject) => {
  531. const updateParamsRecord = {
  532. tableName: masterName,
  533. updList: [
  534. {
  535. where: {
  536. id_: id_
  537. },
  538. param: params
  539. }
  540. ]
  541. }
  542. this.$common
  543. .request('update', updateParamsRecord)
  544. .then((res) => {
  545. this.$message({
  546. message: '添加成功',
  547. type: 'success'
  548. })
  549. resolve()
  550. })
  551. .catch((err) => {
  552. console.log(err)
  553. })
  554. })
  555. },
  556. createSnapshoot(id) {
  557. const { first = '' } = this.$store.getters.level
  558. const url = this.$getReportFile(
  559. '/人员/检验科交接班登记表.rpx',
  560. `id_=${id}&org_=${first}`
  561. )
  562. return new Promise((resolve, reject) => {
  563. this.$common
  564. .snapshoot({
  565. url: url,
  566. name: '交接班登记表' + this.dataShow(new Date()),
  567. type: 'pdf'
  568. })
  569. .then((res) => {
  570. resolve(res.data.id)
  571. })
  572. .catch((error) => {
  573. reject(error)
  574. })
  575. })
  576. },
  577. remind(list) {
  578. list.forEach((item) => {
  579. console.log(item)
  580. const msg = {
  581. subject: '事务催办提醒',
  582. content: `您的交接班还未完成,请尽快处理!`,
  583. receiverId: item,
  584. canreplay: '0'
  585. }
  586. this.$common.sendMsg(msg)
  587. })
  588. this.$message.success('催办成功!')
  589. }
  590. }
  591. }
  592. </script>
  593. <style scoped lang="less">
  594. .demo-ruleForm {
  595. padding: 1% 5% 1% 5%;
  596. .el-form-item {
  597. padding: 1% 0;
  598. }
  599. .footer-btn {
  600. text-align: center;
  601. }
  602. }
  603. /* 使标签文本左对齐 */
  604. /deep/ .el-form-item__label {
  605. text-align: left;
  606. position: relative; /* 使星号能够相对于标签定位 */
  607. padding-left: 1em; /* 为星号预留一些空间 */
  608. }
  609. /* 使用绝对定位让星号不占据空间,并且显示在标签的右侧 */
  610. /deep/ .el-form-item__label::before {
  611. content: '*';
  612. color: #f56c6c; /* 星号颜色 */
  613. position: absolute;
  614. left: 0; /* 星号靠右 */
  615. top: 50%; /* 垂直居中 */
  616. transform: translateY(-50%); /* 垂直居中修正 */
  617. margin: 0;
  618. }
  619. /* 只有当标签是必填项时才显示星号 */
  620. /deep/ .el-form-item__label:not(.is-required)::before {
  621. content: '';
  622. }
  623. /deep/ .el-form-item__content {
  624. margin: 0;
  625. }
  626. /deep/ .el-dialog__footer {
  627. display: flex;
  628. justify-content: center;
  629. }
  630. </style>