人民医院前端

addComDispatch.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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" :readonly="readonly"></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.readonly = true
  174. this.getDetail()
  175. }
  176. window.scrollTo(0,0)
  177. },
  178. methods: {
  179. postImgData(res) {
  180. console.log(res)
  181. },
  182. // 工单类别
  183. postSelectData(e,id) {
  184. this.flaginfo = String(id)
  185. this.valiFormData.WorkOrderCategory = e
  186. if(this.flagid.indexOf(this.flaginfo) > -1) {
  187. this.dicList = [{
  188. F_DicId: 0,
  189. F_DicName: '',
  190. F_Number: 1
  191. }]
  192. }else{
  193. this.dicList = []
  194. }
  195. },
  196. // 综合调度信息
  197. postSelectDic(e, index) {
  198. this.dicList[index].F_DicId = e.split(',')[0]
  199. this.dicList[index].F_DicName = e.split(',')[1]
  200. },
  201. plusClck() {
  202. const params = {
  203. F_DicId: 0,
  204. F_DicName: '',
  205. F_Number: 1
  206. }
  207. this.dicList.push(params)
  208. },
  209. minusClck() {
  210. this.dicList.splice(this.dicList.length - 1, 1)
  211. },
  212. // 申请部门
  213. deptNodeclick(e) {
  214. if (e) {
  215. this.departid = e.value
  216. pageData.getApplicant(e.value, (res, data) => {
  217. this.ApplicantData = res
  218. this.orderApplicantData = data
  219. })
  220. this.valiFormData.Phone = ''
  221. }
  222. },
  223. deptclosed() {
  224. this.valiFormData.ApplicationDept = this.departid
  225. },
  226. //申请人人
  227. changeApplicant(e) {
  228. this.valiFormData.Applicant = e
  229. const user = this.orderApplicantData.find((o) => {
  230. return o.usercode === e.toString()
  231. })
  232. if (user) {
  233. this.valiFormData.Phone = user.usertelphone
  234. }
  235. },
  236. // 指派部门
  237. maintenanceNodeclick(e) {
  238. if(e) {
  239. this.departMain = e.value
  240. pageData.getApplicant(e.value, (res) => {
  241. this.MaintenancerData = res
  242. })
  243. }
  244. },
  245. maintenanceclosed() {
  246. this.valiFormData.DealDept = this.departMain
  247. },
  248. //指派人
  249. changeMaintenancer(e) {
  250. this.valiFormData.DealMan = e
  251. },
  252. // 工单提交
  253. submit(ref) {
  254. this.disabledButton = true
  255. if (this.clickImgState == 1) {
  256. this.valiFormData.File = this.$mHelper.getImgString(this.imgIdList)
  257. }
  258. this.$refs[ref].validate().then(res => {
  259. if(this.workorderid) {
  260. this.valiFormData.WorkOrderCode = this.workorderid
  261. const params = {
  262. usertype: 1,
  263. input: this.valiFormData,
  264. detailists: this.dicList
  265. }
  266. this.$mHelper.httpPost("Scheduling/UpdateSchedulingWorkOrder", this.serialize(params), 1, res => this.disabledButton = res)
  267. }else{
  268. const params = {
  269. cfnum: this.redPrescriptionNum, // 红处方数量
  270. input: this.valiFormData,
  271. detailists: this.dicList
  272. }
  273. this.$mHelper.httpPost("Scheduling/AddSchedulingWorkOrder", this.serialize(params), 1, res => this.disabledButton = res)
  274. }
  275. }).catch(err => {
  276. this.disabledButton = false
  277. console.log('err', err);
  278. })
  279. },
  280. serialize(obj, prefix) {
  281. const str = []
  282. let p
  283. if (obj.length === 0) {
  284. // str.push(encodeURIComponent(prefix) + '=1')
  285. } else {
  286. for (p in obj) {
  287. if (obj.hasOwnProperty(p)) {
  288. const k = prefix ? prefix + '[' + p + ']' : p
  289. let v = obj[p]
  290. if (v instanceof Date) {
  291. v = parseTime(v)
  292. }
  293. str.push((v !== null && typeof v === 'object') ? this.serialize(v, k) : encodeURIComponent(k) +'=' + encodeURIComponent(v))
  294. }
  295. }
  296. }
  297. return str.join('&')
  298. },
  299. getDetail() {
  300. const params = {
  301. WorkOrderCode: this.workorderid,
  302. type: 0
  303. }
  304. this.$http.get("Scheduling/GetWorkOrder", params).then((response) => {
  305. if (response.state.toLowerCase() === "success") {
  306. this.valiFormData.WorkOrderCategory = response.data[0].F_WorkOrderCategory // 工单类别
  307. this.valiFormData.Content = response.data[0].F_Content // 工单内容
  308. if(response.data[0].F_ApplicationDept) {
  309. this.valiFormData.ApplicationDept = response.data[0].F_ApplicationDept.trim() // 申请部门
  310. pageData.getApplicant(this.valiFormData.ApplicationDept, (res) => {
  311. this.ApplicantData = res
  312. })
  313. this.valiFormData.Applicant = response.data[0].F_Applicant //申请人
  314. }
  315. this.valiFormData.Phone = response.data[0].F_Phone // 联系电话
  316. this.valiFormData.Location = response.data[0].F_Location
  317. this.valiFormData.ToPlace = response.data[0].F_ToPlace
  318. this.valiFormData.File = response.data[0].F_File
  319. const ps = []
  320. response.data[0].PSInfo.forEach(v => {
  321. ps.push({
  322. F_DicId: v.F_DicId,
  323. F_DicName: v.F_DicName,
  324. F_Number: v.F_Number
  325. })
  326. })
  327. this.dicList = ps
  328. if (response.data[0].FileUrl) {
  329. response.data[0].FileUrl.forEach((v, n) => {
  330. //详情图片回显
  331. this.imgUrlList.push({
  332. url: v.F_FileUrl,
  333. extname: v.F_FileType,
  334. name: v.F_FileName.substring(19),
  335. id:v.F_FileId
  336. })
  337. })
  338. }
  339. }
  340. }).catch((e) => {
  341. console.log(e);
  342. })
  343. },
  344. // 上传图片
  345. getImgData(data) {
  346. console.log(data)
  347. this.clickImgState = 1
  348. this.imgIdList = data
  349. },
  350. }
  351. }
  352. </script>
  353. <style lang="scss" scoped>
  354. .wrapper {
  355. padding: 10px 15px;
  356. background-color: #fff;
  357. .form {
  358. .infoTittle {
  359. align-items: center;
  360. text-align: left;
  361. font-size: 14px;
  362. color: #606266;
  363. height: 36px;
  364. padding: 0 12px 0 0;
  365. vertical-align: middle;
  366. flex-shrink: 0;
  367. // box-sizing: border-box;
  368. margin-right: 10px;
  369. }
  370. .dicSelect {
  371. width: 65%;
  372. display: inline-block;
  373. margin-right: 10px;
  374. margin-bottom: 15px;
  375. }
  376. .dicNum {
  377. width: 30%;
  378. display: inline-block;
  379. }
  380. /deep/.uni-icons[data-v-a2e81f6e] {
  381. vertical-align: middle;
  382. }
  383. .point {
  384. color: #f00;
  385. vertical-align: middle;
  386. margin-right: 2px;
  387. }
  388. }
  389. }
  390. </style>