人民医院前端

addComDispatch.vue 12KB

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