setNode.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view>
  3. <cu-custom id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="true">
  6. <block slot="backText">返回</block>
  7. <block slot="content">
  8. 工序
  9. </block>
  10. </cu-custom>
  11. <view class="header">
  12. <view class="title">
  13. {{ detail.workpresetjson.workname }}
  14. </view>
  15. <view class="detail-result">
  16. <view class="have-not-begun tag" v-if="detail.status == 0">
  17. 未开始
  18. </view>
  19. <block v-else>
  20. <view class="time">{{ detail.changedate }}</view>
  21. <view class="done tag" v-if="detail.status == 1">
  22. 完成
  23. </view>
  24. <view class="underway tag" v-else>
  25. 进行中
  26. </view>
  27. </block>
  28. </view>
  29. </view>
  30. <My_form ref="My_form" @onConfirm="onConfirm" :isReadOnly="isReadOnly" />
  31. <view class="but-box" v-if="detail.status != 1">
  32. <u-button type="primary" text="确定完成" color="#0054E1" :disabled="disabled" loadingText="执行中..."
  33. :loading="loading" @click="submit(1)" />
  34. <view style="height: 10px;" />
  35. <u-button type="primary" text="保存" color="#0054E1" loadingText="保存中..." :loading="loading1"
  36. @click="submit(0)" />
  37. </view>
  38. <view style="height: 50rpx;" />
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. isReadOnly: false,
  46. detail: {
  47. workpresetjson: {
  48. workname: ""
  49. },
  50. status: 0
  51. },
  52. loading: false,
  53. loading1: false,
  54. disabled: false
  55. }
  56. },
  57. onLoad(options) {
  58. if (options.isReadOnly) this.isReadOnly = true;
  59. this.sa_workorderid = options.sa_workorderid;
  60. this.sa_workorder_nodeid = options.sa_workorder_nodeid;
  61. this.w_deviceid = options.w_deviceid;
  62. this.getDetail();
  63. },
  64. methods: {
  65. getDetail() {
  66. this.$Http.basic({
  67. "id": 20230209091103,
  68. "content": {
  69. "sa_workorderid": this.sa_workorderid,
  70. "sa_workorder_nodeid": this.sa_workorder_nodeid,
  71. }
  72. }).then(res => {
  73. console.log("工单节点详情", res)
  74. if (this.cutoff(res.msg)) return;
  75. this.detail = res.data[0]
  76. this.isReadOnly = this.isReadOnly || this.detail.status == 1;
  77. let form = [{
  78. label: "工序说明",//标题
  79. disabled: true,//禁用
  80. type: 'text',//类型
  81. password: false,//是否密码类型
  82. placeholder: "暂无说明",
  83. value: this.detail.workpresetjson.remarks || '',
  84. maxlength: -1,//最大长度
  85. key: "gxsm",
  86. required: false,//是否必填
  87. }]
  88. const workpresetjson = this.detail.workpresetjson;
  89. if (workpresetjson.textedit !== 0) form.push({
  90. label: "文本信息",
  91. disabled: false,//禁用
  92. type: 'textarea',//类型
  93. value: "",
  94. key: 'textcontent',
  95. maxlength: -1,//最大长度
  96. required: workpresetjson.textedit == 11,//是否必填
  97. });
  98. if (workpresetjson.confirm_options !== 0) form.push({
  99. label: "是否确认",
  100. disabled: false,//禁用
  101. type: 'radio',//类型
  102. value: "是",
  103. options: workpresetjson.confirm_options.map(v => {
  104. return {
  105. value: v
  106. }
  107. }),
  108. showKey: 'value',//必传 唯一值
  109. selectKey: "value",//传值key返回该key的值,不传返回整个选择数据
  110. key: "confirm_value",
  111. required: workpresetjson.confirm == 11,//是否必填
  112. });
  113. if (workpresetjson.fileupload !== 0) form.push({
  114. label: "附件",
  115. disabled: false,//禁用
  116. type: 'file',//类型
  117. isDelete: true,//是否可以删除附件
  118. fileType: ["image", "video", "file"],//可上传类型
  119. key: "attinfos",
  120. value: [],
  121. required: workpresetjson.fileupload == 11,//是否必填
  122. aDeletion: true,//是否为异步删除
  123. });
  124. if (workpresetjson.positioncheck !== 0) {
  125. this.detail.location = {
  126. address: this.detail.address || '',
  127. latitude: this.detail.latitude || '',
  128. longitude: this.detail.longitude || '',
  129. time: this.detail.signdate || '',
  130. }
  131. form.push({
  132. label: "签到",
  133. type: 'location',//类型
  134. key: "location",
  135. value: {},
  136. required: workpresetjson.positioncheck == 11,//是否必填
  137. });
  138. }
  139. if (workpresetjson.paramcheck !== 0) form.push({
  140. label: "设备点位",
  141. type: 'route',//类型
  142. disabled: false,
  143. path: "/select/points",
  144. showKey: "paramname",
  145. idKey: 'w_dataparamid',
  146. param: {
  147. "id": 20230613091602,
  148. "content": {
  149. "ownertable": "w_device",
  150. "ownerid": this.w_deviceid,
  151. "where": { "condition": "" }
  152. }
  153. },
  154. key: "param",
  155. value: [],
  156. required: workpresetjson.paramcheck == 11,
  157. });
  158. form.push({
  159. label: "备注",
  160. disabled: false,//禁用
  161. type: 'textarea',//类型
  162. placeholder: "",
  163. value: "",
  164. key: 'remarks',
  165. maxlength: -1,//最大长度
  166. required: false,//是否必填
  167. });
  168. this.$refs.My_form.render(form, this.detail)
  169. })
  170. },
  171. submit(isconfirm) {
  172. let content = {
  173. "sa_workorderid": this.sa_workorderid,
  174. "sa_workorder_nodeid": this.sa_workorder_nodeid,
  175. isconfirm,
  176. params: [],
  177. ...this.$refs.My_form.onSubmit()
  178. }
  179. content = Object.assign(content, content.location);
  180. content.signdate = content.time || '';
  181. delete content.location;
  182. delete content.time;
  183. if (isconfirm == 1) {
  184. this.loading = true;
  185. } else {
  186. this.loading1 = true;
  187. }
  188. Promise.all([this.$refs.My_form.handleFileLink(content.attachmentids, "sa_workorder_node", this.sa_workorder_nodeid), this.$refs.My_form.handleDeteleFiles(content.linksids)]).then(s => {
  189. console.log("绑定附件回调", s)
  190. delete content.attinfos;
  191. this.$Http.basic({
  192. "id": 20230209094203,
  193. content
  194. }).then(res => {
  195. console.log("保存工序", res)
  196. this.loading = false;
  197. this.loading1 = false;
  198. if (this.cutoff(res.msg, isconfirm == 1 ? '确定完成工序成功' : '保存成功')) return;
  199. this.getDetail(true)
  200. console.log(this.$Http)
  201. this.$Http.updateNodes && this.$Http.updateNodes(true)
  202. })
  203. })
  204. },
  205. onConfirm(bool) {
  206. this.disabled = bool;
  207. }
  208. },
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .header {
  213. position: relative;
  214. padding: 10px;
  215. width: 355px;
  216. margin: 10px auto;
  217. background: #fff;
  218. border-radius: 4px;
  219. box-sizing: border-box;
  220. .title {
  221. font-size: 16px;
  222. font-weight: bold;
  223. }
  224. .detail-result {
  225. margin-top: 4px;
  226. display: flex;
  227. align-items: center;
  228. .have-not-begun {
  229. background: #E34D59;
  230. }
  231. .done {
  232. background: #4BA574;
  233. }
  234. .underway {
  235. background: #2151D1;
  236. }
  237. .tag {
  238. font-size: 10px;
  239. padding: 4px;
  240. border-radius: 4px;
  241. color: #fff;
  242. margin-right: 6px;
  243. }
  244. .time {
  245. font-size: 14px;
  246. color: #999;
  247. margin-right: 6px;
  248. }
  249. }
  250. }
  251. .but-box {
  252. width: 355px;
  253. margin: 20px auto 0;
  254. /deep/ .u-button__text,
  255. /deep/.u-button__loading-text {
  256. font-size: 14px !important;
  257. font-weight: bold;
  258. }
  259. /deep/.u-loading-icon__spinner {
  260. width: 17.25px !important;
  261. height: 17.25px !important;
  262. }
  263. }
  264. </style>