123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612 |
- <template>
- <div class="formwrap">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane label="用户管理" name="customerEdit">
- <el-form ref="editForm" :model="formmodel" :rules="rules" label-width="140px">
- <el-row>
- <el-col :span="8">
- <el-form-item label="用户姓名" prop="named">
- <el-input v-model="formmodel.named" clearable placeholder="请输入姓名" :maxlength="20" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="用户编号">
- <el-input v-model="formmodel.card_no" clearable placeholder="请输入用户编号" :maxlength="20" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="年龄" prop="age">
- <el-input v-model="formmodel.age" clearable :maxlength="4" placeholder="请输入年龄">
- <el-select slot="append" v-model="formmodel.age_unit" placeholder="请选择年龄单位">
- <el-option label="岁" value="岁" />
- <el-option label="月" value="月" />
- <el-option label="天" value="天" />
- </el-select>
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="性别" class="form-item-sex">
- <el-radio v-model="formmodel.sex" :label="1">男</el-radio>
- <el-radio v-model="formmodel.sex" :label="0">女</el-radio>
- <el-radio v-model="formmodel.sex" :label="3">未知</el-radio>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="在院状态">
- <el-radio v-model="formmodel.status" :label="0">在院</el-radio>
- <el-radio v-model="formmodel.status" :label="1">已出院</el-radio>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="证件类型">
- <el-radio v-model="formmodel.id_type" label="身份证">身份证</el-radio>
- <el-radio v-model="formmodel.id_type" label="护照">护照</el-radio>
- <el-radio v-model="formmodel.id_type" label="军人证">军人证</el-radio>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="证件号">
- <el-input v-model="formmodel.id_no" clearable placeholder="请输入证件号" :maxlength="20" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="入院日期" prop="in_date">
- <el-date-picker
- v-model="formmodel.in_date"
- type="date"
- :editable="false"
- value-format="timestamp"
- placeholder="选择入院日期"
- :picker-options="{disabledDate(time) { return time.getTime() > Date.now() }}"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="出院日期" prop="out_date">
- <el-date-picker
- v-model="formmodel.out_date"
- type="date"
- :editable="false"
- value-format="timestamp"
- placeholder="选择出院日期"
- :picker-options="{disabledDate(time) { return time.getTime() < Date.now() }}"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="8">
- <el-form-item label="责任医生">
- <el-select v-model="formmodel.doctor_id" placeholder="请选择医生" @change="doctorChange(1)">
- <el-option v-for="(item,index) in doctors" :key="index" :label="item.clerk_name" :value="item.clerk_id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="责任护士">
- <el-select v-model="formmodel.nurse_id" placeholder="请选择护士" @change="doctorChange(2)">
- <el-option v-for="(item,index) in nurses" :key="index" :label="item.clerk_name" :value="item.clerk_id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="责任护工">
- <el-select v-model="formmodel.worker_id" placeholder="请选择护工" @change="doctorChange(3)">
- <el-option v-for="(item,index) in workrs" :key="index" :label="item.clerk_name" :value="item.clerk_id" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row v-if="nurseData.length > 0">
- <el-col v-for="(item, index) in nurseList" :key="index" :span="24 / nurseList.length">
- <el-form-item :label="item[0]">
- <el-select v-model="nurseData[index].nurse_level" :placeholder="'请选择'+item[0]" @change="changeNurseData(index)">
- <el-option v-for="(t,i) in item[1]" :key="i" :label="t.option_name" :value="t.id">
- <span style="float: left">{{ t.option_name }}</span>
- <span :style="'float: right; background-color: #'+t.color_rgb+';color: #'+t.color_rgb">颜色</span>
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="16">
- <el-form-item label="病况描述">
- <el-input
- v-model="formmodel.illness_desc"
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 4}"
- :minlength="2"
- :maxlength="50"
- :placeholder="'请输入文本内容,长度2~50'"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item style="margin-top:15px;">
- <el-button type="primary" :disabled="isDisabled" class="save" @click="handlerSubmit('editForm')">保存修改</el-button>
- </el-form-item>
- </el-form>
- <el-card v-if="this.customerId != 0" style="maring:15px">
- <div>
- <div style="float: left"><h4>用户备注</h4></div>
- <div style="float: right">
- <el-button type="success" @click="dialogAddVisible = true">添加备注</el-button>
- </div>
- </div>
- <div style="clear:both">
- <div>
- <el-card v-for="(item, index) in tableData" :key="index">
- <div>
- <span style="margin-left: 20px;font-weight:bold">备注内容:</span><span style="line-height:1.5">{{ item.content }}</span>
- </div>
- <div style="margin: 10px">
- <div style="float: left">
- <span v-if="item.file_name">
- <el-link :href="item.file_path" icon="el-icon-folder" type="success" target="_blank" :download="item.file_name">{{ item.file_name }}</el-link>
- </span>
- </div>
- <div style="float: right">
- <p>
- <span style="font-weight:bold">创建时间:</span>{{ forDate(item.create_time) }}
- <span style="font-weight:bold;margin-left: 10px;">创建人:</span>{{ item.create_name }}
- </p>
- </div>
- </div>
- </el-card>
- <!--翻页-->
- <el-pagination
- v-if="pageData"
- slot="pagination"
- :current-page="pageData.page_no"
- :page-sizes="[10, 30, 50, 100]"
- :page-size="pageData.page_size"
- layout="total, sizes, prev, pager, next, jumper"
- :total="pageData.data_total"
- @size-change="handlePageSizeChange"
- @current-change="handlePageCurrentChange"
- />
- </div>
- </div>
- </el-card>
- <el-dialog title="添加用户备注" :visible.sync="dialogAddVisible" :append-to-body="true" width="80%">
- <el-form ref="editForm" :model="formmodel" :rules="rules" label-width="140px">
- <el-form-item label="内容" prop="content">
- <el-input
- v-model="content"
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 6}"
- :minlength="2"
- :maxlength="300"
- show-word-limit
- :placeholder="'请输入文本内容,长度300'"
- />
- </el-form-item>
- <el-form-item label="附件">
- <el-upload
- v-if="!filePath"
- class="avatar-uploader"
- :action="`${uploadServer}?scene=avatar`"
- :show-file-list="false"
- :on-success="uploaded"
- :before-upload="handleShopLogoBefore"
- >
- <i class="el-icon-plus avatar-uploader-icon" />
- </el-upload>
- <span v-if="filePath">{{ fileName }}</span>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="addRemark">立即添加</el-button>
- <el-button @click="quxiao">取消</el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
- </el-tab-pane>
- <el-tab-pane v-if="customerId != 0" label="用户亲属" name="customer-relative">
- <customer-relative :member-id="memberId" />
- </el-tab-pane>
- </el-tabs>
- </div>
- </template>
- <script>
- import * as customer_API from '@/api/ncs_customer'
- import * as clerk_API from '@/api/ncs_clerk'
- import * as NurseConfig_API from '@/api/ncs_nurse_config'
- import * as remark_API from '@/api/ncs_remark'
- import * as RegExp from '@/utils/RegExp'
- import { unixToDate } from '@/utils/Foundation'
- // import { serverUrl } from '@/utils/domain'
- import customerRelative from '@/views/customer/customer_relative'
- const serverUrl = domain.serverUrl
- export default {
- name: 'PatientInfoEdit',
- components: { customerRelative },
- props: {
- customerId: {
- type: Number,
- default: 0
- },
- frameId: {
- type: Number,
- default: 0
- }
- },
- data: function() {
- return {
- formmodel: {
- sex: 1,
- status: 0,
- age_unit: '岁',
- id_type: '身份证',
- part_id: this.$store.getters.partId
- },
- nurseList: [],
- nurseData: [],
- nurseConfigDtos: [],
- rules: {
- named: [
- this.MixinRequired('请输入真实姓名!'),
- { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' },
- {
- validator: (rule, value, callback) => {
- if (!RegExp.userName.test(value)) {
- callback(new Error('只支持汉字、字母、数字、“-”、“_”的组合!'))
- } else {
- callback()
- }
- }
- }
- ],
- age: [{ required: true, message: '请输入年龄', trigger: 'blur' }],
- content: [{ required: true, message: '请输入备注内容', trigger: 'blur' }],
- in_date: [{ required: true, message: '请选择入院日期', trigger: 'blur' }]
- },
- isDisabled: false,
- doctors: [],
- nurses: [],
- workrs: [],
- doctor_mapping_id: false,
- nurse_Mapping_id: false,
- worker_mapping_id: false,
- params: {
- page_size: 10,
- page_no: 1,
- sort: 'create_time',
- dir: 'desc'
- },
- tableData: [],
- pageData: [],
- dialogAddVisible: false,
- fileName: null,
- filePath: null,
- uploadServer: serverUrl + '/ncs/upload/uploadFile',
- userInfo: this.$store.getters.userInfo,
- content: null,
- activeName: 'customerEdit',
- memberId: null
- }
- },
- watch: {
- frameId: function(newval) {
- this.getNurseConfigs()
- this.hasCustomerId()
- }
- },
- mounted() {
- this.getEmployees()
- if (this.nurseList.length === 0) {
- this.getNurseConfigs()
- this.hasCustomerId()
- }
- },
- methods: {
- getEmployees() {
- const _this = this
- clerk_API.listByPartRoleId({ partId: this.$store.getters.partId }).then(res => {
- const groupBy = (arr, func) =>
- arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => {
- acc[val] = (acc[val] || []).concat(arr[i])
- return acc
- }, {})
- const groupData = groupBy(res, item => item.role_name)
- if (Object.entries(groupData).length > 0) {
- Object.entries(groupData).forEach(item => {
- if (item[0] === '医生') {
- _this.doctors = item[1]
- } else if (item[0] === '护士') {
- _this.nurses = item[1]
- } else if (item[0] === '护工') {
- _this.workrs = item[1]
- }
- })
- }
- })
- },
- getNurseConfigs() {
- this.nurseData = []
- const _this = this
- NurseConfig_API.listByPartId({ partId: this.$store.getters.partId }).then(res => {
- const groupBy = (arr, func) =>
- arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => {
- acc[val] = (acc[val] || []).concat(arr[i])
- return acc
- }, {})
- // 以参数名称来分组
- const groupData = groupBy(res, item => item.config_name)
- _this.nurseList = Object.entries(groupData)
- if (_this.nurseList.length > 0) {
- _this.nurseList.forEach((item, index) => {
- _this.nurseData.push({ nurse_level: null, id: null, nurse_config: item[1][0].ncfg_id })
- })
- }
- })
- },
- hasCustomerId() {
- this.clearForm()
- if (this.customerId !== 0) {
- const _this = this
- customer_API.getCustomerInfo(this.customerId).then(res => {
- _this.formmodel = res
- _this.doctor_mapping_id = res.doctor_mapping_id
- _this.nurse_Mapping_id = res.nurse_Mapping_id
- _this.worker_mapping_id = res.worker_mapping_id
- _this.formmodel.doctor_mapping_id = null
- _this.formmodel.nurse_Mapping_id = null
- _this.formmodel.worker_mapping_id = null
- if (_this.formmodel.in_date) {
- _this.formmodel.in_date = _this.formmodel.in_date * 1000
- }
- if (_this.formmodel.out_date) {
- _this.formmodel.out_date = _this.formmodel.out_date * 1000
- }
- console.log(_this.formmodel.in_date, _this.formmodel.out_date)
- _this.getRemarks()
- if (res.list !== null) {
- _this.nurseData.forEach((item, index) => {
- res.list.forEach((t, i) => { // 为护理项赋值
- if (item.nurse_config === t.nurse_config) {
- item.nurse_level = t.nurse_level
- item.id = t.id
- }
- })
- })
- }
- })
- }
- },
- doctorChange(type) {
- if (this.customerId !== 0) {
- if (type === 1) {
- if (this.doctor_mapping_id === null) {
- this.formmodel.doctor_mapping_id = 0 // 为0则新增,// 其他值为修改
- } else {
- this.formmodel.doctor_mapping_id = this.doctor_mapping_id
- }
- } else if (type === 2) {
- if (this.nurse_Mapping_id === null) {
- this.formmodel.nurse_Mapping_id = 0 // 为0则新增,// 其他值为修改
- } else {
- this.formmodel.nurse_Mapping_id = this.nurse_Mapping_id
- }
- } else {
- if (this.worker_mapping_id === null) {
- this.formmodel.worker_mapping_id = 0 // 为0则新增,// 其他值为修改
- } else {
- this.formmodel.worker_mapping_id = this.worker_mapping_id
- }
- }
- }
- },
- /** 保存按钮处理事件 */
- handlerSubmit(formName) {
- this.$refs[formName].validate(valid => {
- if (valid) {
- this.isDisabled = true
- if (this.formmodel.in_date) {
- this.formmodel.in_date = this.formmodel.in_date / 1000
- }
- if (this.formmodel.out_date) {
- this.formmodel.out_date = this.formmodel.out_date / 1000
- }
- if (this.customerId === 0) {
- this.formmodel.frame_id = this.frameId
- this.formmodel.list = this.nurseConfigDtos
- customer_API.addAll(this.formmodel).then(res => {
- this.$message.success(this.$t('action.addSuccess2'))
- this.clearForm()
- this.$emit('saved')
- }).catch(e => {
- this.isDisabled = false
- })
- } else {
- this.formmodel.list = this.nurseConfigDtos
- customer_API.updateAll(this.formmodel).then(res => {
- this.$message.success(this.$t('action.editSuccess'))
- this.isDisabled = false
- this.$emit('saved')
- })
- }
- } else {
- this.$message.error(this.$t('action.fromError'))
- return false
- }
- })
- },
- clearForm() {
- this.activeName = 'customerEdit'
- this.formmodel = {
- sex: 1,
- status: 0,
- age_unit: '岁',
- id_type: '身份证',
- part_id: this.$store.getters.partId,
- named: null,
- card_no: null,
- id_no: null,
- in_date: new Date(new Date().toLocaleDateString()).getTime(),
- out_date: null,
- doctor_id: null,
- nurse_id: null,
- worker_id: null,
- illness_desc: null
- }
- this.isDisabled = false
- this.nurseConfigDtos = []
- },
- // 选择了护理项
- changeNurseData(index) {
- const i = this.nurseConfigDtos.findIndex(item => {
- return item.nurse_level === this.nurseData[index].nurse_level
- })
- if (i !== -1) {
- this.nurseConfigDtos.splice(i, 1)
- }
- this.nurseConfigDtos.push(this.nurseData[index])
- },
- getRemarks() {
- const _this = this
- this.params.fixedCondition = ' part_id=' + this.$store.getters.partId + ' and type=1 and member_id = ' + this.formmodel.member_id
- remark_API.getRemarks(this.params).then(res => {
- _this.tableData = res.data
- _this.pageData = {
- page_no: res.page_no,
- page_size: res.page_size,
- data_total: res.data_total
- }
- })
- },
- /** 分页大小发生改变 */
- handlePageSizeChange(size) {
- this.params.page_size = size
- this.getRemarks()
- },
- /** 分页页数发生改变 */
- handlePageCurrentChange(page) {
- this.params.page_no = page
- this.getRemarks()
- },
- forDate(date) {
- return unixToDate(date)
- },
- /** 上传成功后的钩子 更换图片 置空存储数组*/
- uploaded(res) {
- this.filePath = serverUrl + '/' + res
- },
- /** 图片上传之前的校验 */
- handleShopLogoBefore(file) {
- const _this = this
- return new Promise((resolve, reject) => {
- let hz = file.name
- _this.fileName = hz
- const index = hz.lastIndexOf('.')
- hz = hz.substring(index + 1, hz.length)
- const isImg = hz === 'jpeg' || hz === 'png' || hz === 'jpg' || hz === 'txt' || hz === 'doc' || hz === 'docx' || hz === 'xls' || hz === 'xlsx'
- const isLt5M = file.size / 1024 / 1024 < 5
- if (!isImg) {
- _this.$message.error('上传附件只能是txt,doc,docx,xls,xlsx,jpg,png,jpeg格式!')
- reject()
- }
- if (!isLt5M) {
- _this.$message.error('上传附件大小不能超过 5MB!')
- reject()
- }
- resolve()
- })
- },
- addRemark() {
- if (!this.content) {
- this.$message.info('请输入内容!')
- return
- }
- if (!this.filePath) {
- this.fileName = null
- }
- const data = {
- partId: this.$store.getters.partId,
- type: 1,
- memberId: this.formmodel.member_id,
- createName: this.userInfo.username,
- content: this.content,
- filePath: this.filePath,
- fileName: this.fileName
- }
- const _this = this
- remark_API.save(data).then(res => {
- _this.$message.success(this.$t('action.addSuccess2'))
- _this.getRemarks()
- _this.quxiao()
- })
- },
- quxiao() {
- this.dialogAddVisible = false
- this.content = null
- this.fileName = null
- this.filePath = null
- },
- handleClick(tab) {
- this.memberId = this.formmodel.member_id
- }
- }
- }
- </script>
- <style type="text/scss" scoped>
- .el-input .el-select {
- width: 68px;
- }
- .el-select {
- width: 100%;
- }
- .formwrap {
- border: 1px solid #ebebeb;
- border-radius: 3px;
- background: #fff;
- padding: 24px;
- min-height: 500px;
- }
- /deep/ .avatar-uploader .el-upload {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- /deep/ .avatar-uploader .el-upload:hover {
- border-color: #409EFF;
- }
- /deep/ .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 100px;
- height: 100px;
- line-height: 100px;
- text-align: center;
- }
- /deep/ .avatar {
- width: 100px;
- height: 100px;
- display: block;
- }
- </style>
|