人民医院前端

addComDispatch.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view class="wrapper">
  3. <view class="form">
  4. <!-- 基础表单校验 -->
  5. <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData">
  6. <uni-forms-item label="工单类别" required name="WorkOrderCategory">
  7. <order-select :orderType="valiFormData.WorkOrderCategory" @post-select-data="postSelectData"
  8. :typeid="2000"></order-select>
  9. </uni-forms-item>
  10. <uni-forms-item label="申请部门" required name="ApplicationDept">
  11. <uni-data-picker placeholder="请选择申请部门" :localdata="deptDataTree"
  12. v-model="valiFormData.ApplicationDept" @nodeclick="deptNodeclick" @popupclosed="deptclosed">
  13. </uni-data-picker>
  14. </uni-forms-item>
  15. <uni-forms-item label="申请人" required name="Applicant">
  16. <uni-data-select v-model="valiFormData.Applicant" :localdata="ApplicantData"
  17. @change="changeApplicant" />
  18. </uni-forms-item>
  19. <uni-forms-item label="联系电话" required name="Phone">
  20. <uni-easyinput v-model="valiFormData.Phone" placeholder="请输入联系电话" />
  21. </uni-forms-item>
  22. <uni-forms-item label="科室位置" required name="Location">
  23. <uni-easyinput v-model="valiFormData.Location" placeholder="请输入科室位置" />
  24. </uni-forms-item>
  25. <view style="margin: 15px 0;" v-show="valiFormData.WorkOrderCategory && flag[flaginfo]">
  26. <view style="margin-bottom: 15px;">
  27. <text class="point">*</text><text class="infoTittle">{{flagName[flaginfo]}}</text>
  28. <uni-icons type="plus" size="30" color="#007aff" @click="plusClck()"></uni-icons>
  29. <uni-icons type="minus" size="30" color="#007aff" @click="minusClck()"></uni-icons>
  30. </view>
  31. <view style="width: 100%;height: 50px;" v-for="(item, index) in dicList">
  32. <view class="dicSelect">
  33. <dictionaries-select :flag="flag[flaginfo]" :valInfo="index" :val="item.F_DicId + ','+ item.F_DicName"
  34. @post-select-dic="postSelectDic"></dictionaries-select>
  35. </view>
  36. <view class="dicNum">
  37. <uni-number-box v-model="item.F_Number" />
  38. </view>
  39. </view>
  40. </view>
  41. <uni-forms-item label="送达地点" required name="ToPlace">
  42. <uni-easyinput v-model="valiFormData.ToPlace" placeholder="请输入送达地点" />
  43. </uni-forms-item>
  44. <uni-forms-item label="工单内容" required name="Content">
  45. <uni-easyinput type="textarea" v-model="valiFormData.Content" placeholder="请输入工单内容" />
  46. </uni-forms-item>
  47. <uni-forms-item label="红处方数量" required name="redPrescriptionNum" v-show="flaginfo == '2004' ">
  48. <uni-number-box v-model="redPrescriptionNum" />
  49. </uni-forms-item>
  50. <uni-forms-item label="附件" name="">
  51. <view class="example-body">
  52. <!-- <uni-file-picker limit="5" file-mediatype="all" @select="select" @success="success" @delete="deleteFile"></uni-file-picker> -->
  53. <upload @post-string-data="getImgData" :fileUrlList="imgUrlList"></upload>
  54. </view>
  55. </uni-forms-item>
  56. </uni-forms>
  57. <view class="btnClass">
  58. <button type="primary" :disabled="disabledButton" @click="submit('valiForm')">提交工单</button>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import orderSelect from "@/pages/components/orderSelect/orderSelect"
  65. import {
  66. filterTreeDatas,
  67. filterSelectData
  68. } from '@/utils/dataTreating.js'
  69. import pageData from "@/pages/myTask/repairList/addRepair/pageData.js"
  70. import upload from '@/pages/components/upload/uploadFile.vue' //upload
  71. import dictionariesSelect from '@/pages/components/dictionariesSelect/dictionariesSelect.vue' //upload
  72. export default {
  73. components: {
  74. upload,
  75. orderSelect,
  76. dictionariesSelect
  77. },
  78. data() {
  79. return {
  80. isShowIsEnd: false,
  81. readonly: false,
  82. disabledButton: false,
  83. // 校验表单数据
  84. valiFormData: {
  85. WorkOrderCategory: '', //工单类别
  86. ApplicationDept: '', //申请部门
  87. Applicant: '', //申请人
  88. Phone: '', //联系电话
  89. Location: '', // 科室位置
  90. ToPlace: '', // 送达地点
  91. Content: '', // 工单内容
  92. DealDept: '', // 维修部门
  93. DealMan: '', // 维修人
  94. File: '', // 文件
  95. },
  96. redPrescriptionNum: 0, // 红处方数量
  97. workorderid: '',
  98. stepData: pageData.stepData,
  99. departid: '',
  100. departMain: '',
  101. imgUrlList: [], // 附件数据
  102. imgIdList: [], //上传附件id
  103. clickImgState: 0, // 图片回显的状态
  104. deptDataTree: [], // 科室-部门数据
  105. ApplicantData: [], // 获取人员数据
  106. assignedDepartData: [], //指派部门数据
  107. MaintenancerData: [], //指派人数据
  108. orderApplicantData: [], // 用户人员信息
  109. // 标本信息(BBXX),设备信息(SBXX),物资信息(WZXX),病床信息(BCXX),药品信息(YPXX)
  110. flagid: ["2001","2002","2003","2006","2005"],
  111. flaginfo: '',
  112. flag: {
  113. "2006": 'BBXX',
  114. "2001": 'SBXX',
  115. "2002": 'WZXX',
  116. "2003": 'BCXX',
  117. "2005": 'YPXX'
  118. },
  119. flagName: {
  120. "2001": '设备信息',
  121. "2002": '物资信息',
  122. "2003": '病床信息',
  123. "2006": '标本信息',
  124. "2005": '药品信息'
  125. },
  126. dicList: [{
  127. F_DicId: 0,
  128. F_DicName: '',
  129. F_Number: 1
  130. }],
  131. // 校验规则
  132. rules: {
  133. WorkOrderCategory: {
  134. rules: [{
  135. required: true,
  136. errorMessage: '请选择工单类别'
  137. }]
  138. },
  139. ApplicationDept: {
  140. rules: [{
  141. required: true,
  142. errorMessage: '请选择申请科室'
  143. }]
  144. },
  145. Applicant: {
  146. rules: [{
  147. required: true,
  148. errorMessage: '请选择申请人'
  149. }]
  150. },
  151. Phone: {
  152. rules: [{
  153. required: true,
  154. errorMessage: '清输入联系电话'
  155. }]
  156. }
  157. },
  158. }
  159. },
  160. onLoad(option) {
  161. // 部门数据
  162. pageData.getDet((res, data) => {
  163. this.deptDataTree = res
  164. this.assignedDepartData = res
  165. })
  166. this.workorderid = option.wid
  167. if(this.workorderid) {
  168. this.getDetail()
  169. }
  170. window.scrollTo(0,0)
  171. },
  172. methods: {
  173. // 工单类别
  174. postSelectData(e,id) {
  175. this.flaginfo = String(id)
  176. this.valiFormData.WorkOrderCategory = e
  177. if(this.flagid.indexOf(this.flaginfo) > -1) {
  178. this.dicList = [{
  179. F_DicId: 0,
  180. F_DicName: '',
  181. F_Number: 1
  182. }]
  183. }else{
  184. this.dicList = []
  185. }
  186. },
  187. // 综合调度信息
  188. postSelectDic(e, index) {
  189. this.dicList[index].F_DicId = e.split(',')[0]
  190. this.dicList[index].F_DicName = e.split(',')[1]
  191. },
  192. plusClck() {
  193. const params = {
  194. F_DicId: 0,
  195. F_DicName: '',
  196. F_Number: 1
  197. }
  198. this.dicList.push(params)
  199. },
  200. minusClck() {
  201. this.dicList.splice(this.dicList.length - 1, 1)
  202. },
  203. // 申请部门
  204. deptNodeclick(e) {
  205. if (e) {
  206. this.departid = e.value
  207. pageData.getApplicant(e.value, (res, data) => {
  208. this.ApplicantData = res
  209. this.orderApplicantData = data
  210. })
  211. this.valiFormData.Phone = ''
  212. }
  213. },
  214. deptclosed() {
  215. this.valiFormData.ApplicationDept = this.departid
  216. },
  217. //申请人人
  218. changeApplicant(e) {
  219. this.valiFormData.Applicant = e
  220. const user = this.orderApplicantData.find((o) => {
  221. return o.usercode === e.toString()
  222. })
  223. if (user) {
  224. this.valiFormData.Phone = user.usertelphone
  225. }
  226. },
  227. // 指派部门
  228. maintenanceNodeclick(e) {
  229. if(e) {
  230. this.departMain = e.value
  231. pageData.getApplicant(e.value, (res) => {
  232. this.MaintenancerData = res
  233. })
  234. }
  235. },
  236. maintenanceclosed() {
  237. this.valiFormData.DealDept = this.departMain
  238. },
  239. //指派人
  240. changeMaintenancer(e) {
  241. this.valiFormData.DealMan = e
  242. },
  243. // 工单提交
  244. submit(ref) {
  245. this.disabledButton = true
  246. if (this.clickImgState == 1) {
  247. this.valiFormData.File = this.$mHelper.getImgString(this.imgIdList)
  248. }
  249. this.$refs[ref].validate().then(res => {
  250. if(this.workorderid) {
  251. this.valiFormData.WorkOrderCode = this.workorderid
  252. const params = {
  253. usertype: 1,
  254. input: this.valiFormData,
  255. detailists: this.dicList
  256. }
  257. this.$mHelper.httpPost("Scheduling/UpdateSchedulingWorkOrder", this.serialize(params), 1, res => this.disabledButton = res)
  258. }else{
  259. const params = {
  260. cfnum: this.redPrescriptionNum, // 红处方数量
  261. input: this.valiFormData,
  262. detailists: this.dicList
  263. }
  264. this.$mHelper.httpPost("Scheduling/AddSchedulingWorkOrder", this.serialize(params), 1, res => this.disabledButton = res)
  265. }
  266. }).catch(err => {
  267. this.disabledButton = false
  268. console.log('err', err);
  269. })
  270. },
  271. serialize(obj, prefix) {
  272. const str = []
  273. let p
  274. if (obj.length === 0) {
  275. // str.push(encodeURIComponent(prefix) + '=1')
  276. } else {
  277. for (p in obj) {
  278. if (obj.hasOwnProperty(p)) {
  279. const k = prefix ? prefix + '[' + p + ']' : p
  280. let v = obj[p]
  281. if (v instanceof Date) {
  282. v = parseTime(v)
  283. }
  284. str.push((v !== null && typeof v === 'object') ? this.serialize(v, k) : encodeURIComponent(k) +'=' + encodeURIComponent(v))
  285. }
  286. }
  287. }
  288. return str.join('&')
  289. },
  290. getDetail() {
  291. const params = {
  292. WorkOrderCode: this.workorderid,
  293. type: 0
  294. }
  295. this.$http.get("Scheduling/GetWorkOrder", params).then((response) => {
  296. if (response.state.toLowerCase() === "success") {
  297. this.valiFormData.WorkOrderCategory = response.data[0].F_WorkOrderCategory // 工单类别
  298. this.valiFormData.Content = response.data[0].F_Content // 工单内容
  299. if(response.data[0].F_ApplicationDept) {
  300. this.valiFormData.ApplicationDept = response.data[0].F_ApplicationDept.trim() // 申请部门
  301. pageData.getApplicant(this.valiFormData.ApplicationDept, (res) => {
  302. this.ApplicantData = res
  303. })
  304. this.valiFormData.Applicant = response.data[0].F_Applicant //申请人
  305. }
  306. this.valiFormData.Phone = response.data[0].F_Phone // 联系电话
  307. this.valiFormData.Location = response.data[0].F_Location
  308. this.valiFormData.ToPlace = response.data[0].F_ToPlace
  309. this.valiFormData.File = response.data[0].F_File
  310. const ps = []
  311. response.data[0].PSInfo.forEach(v => {
  312. ps.push({
  313. F_DicId: v.F_DicId,
  314. F_DicName: v.F_DicName,
  315. F_Number: v.F_Number
  316. })
  317. })
  318. this.dicList = ps
  319. if (response.data[0].FileUrl) {
  320. response.data[0].FileUrl.forEach((v, n) => {
  321. //详情图片回显
  322. this.imgUrlList.push({
  323. url: v.F_FileUrl,
  324. extname: v.F_FileType,
  325. name: v.F_FileName.substring(19),
  326. id:v.F_FileId
  327. })
  328. })
  329. }
  330. }
  331. }).catch((e) => {
  332. console.log(e);
  333. })
  334. },
  335. // 上传图片
  336. getImgData(data) {
  337. console.log(data)
  338. this.clickImgState = 1
  339. this.imgIdList = data
  340. },
  341. }
  342. }
  343. </script>
  344. <style lang="scss" scoped>
  345. .wrapper {
  346. padding: 10px 15px;
  347. background-color: #fff;
  348. .form {
  349. .infoTittle {
  350. align-items: center;
  351. text-align: left;
  352. font-size: 14px;
  353. color: #606266;
  354. height: 36px;
  355. padding: 0 12px 0 0;
  356. vertical-align: middle;
  357. flex-shrink: 0;
  358. // box-sizing: border-box;
  359. margin-right: 10px;
  360. }
  361. .dicSelect {
  362. width: 65%;
  363. display: inline-block;
  364. margin-right: 10px;
  365. margin-bottom: 15px;
  366. }
  367. .dicNum {
  368. width: 30%;
  369. display: inline-block;
  370. }
  371. /deep/.uni-icons[data-v-a2e81f6e] {
  372. vertical-align: middle;
  373. }
  374. .point {
  375. color: #f00;
  376. vertical-align: middle;
  377. margin-right: 2px;
  378. }
  379. }
  380. }
  381. </style>