人民医院前端

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