setNode.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. try {
  78. this.detail.params = this.detail.params[0];
  79. } catch (error) {
  80. this.detail.params = {
  81. value: [],
  82. showList: []
  83. };
  84. }
  85. let form = [{
  86. label: "工序说明",//标题
  87. disabled: true,//禁用
  88. type: 'text',//类型
  89. password: false,//是否密码类型
  90. placeholder: "暂无说明",
  91. value: this.detail.workpresetjson.remarks || '',
  92. maxlength: -1,//最大长度
  93. key: "gxsm",
  94. required: false,//是否必填
  95. }]
  96. const workpresetjson = this.detail.workpresetjson;
  97. if (workpresetjson.textedit !== 0) form.push({
  98. label: "文本信息",
  99. disabled: false,//禁用
  100. type: 'textarea',//类型
  101. value: "",
  102. key: 'textcontent',
  103. maxlength: -1,//最大长度
  104. required: workpresetjson.textedit == 11,//是否必填
  105. });
  106. if (workpresetjson.confirm_options !== 0) form.push({
  107. label: "是否确认",
  108. disabled: false,//禁用
  109. type: 'radio',//类型
  110. value: "是",
  111. options: workpresetjson.confirm_options.map(v => {
  112. return {
  113. value: v
  114. }
  115. }),
  116. showKey: 'value',//必传 唯一值
  117. selectKey: "value",//传值key返回该key的值,不传返回整个选择数据
  118. key: "confirm_value",
  119. required: workpresetjson.confirm == 11,//是否必填
  120. });
  121. if (workpresetjson.fileupload !== 0) form.push({
  122. label: "附件",
  123. disabled: false,//禁用
  124. type: 'file',//类型
  125. isDelete: true,//是否可以删除附件
  126. fileType: ["image", "video", "file"],//可上传类型
  127. key: "attinfos",
  128. value: [],
  129. required: workpresetjson.fileupload == 11,//是否必填
  130. aDeletion: true,//是否为异步删除
  131. });
  132. if (workpresetjson.positioncheck !== 0) {
  133. this.detail.location = {
  134. address: this.detail.address || '',
  135. latitude: this.detail.latitude || '',
  136. longitude: this.detail.longitude || '',
  137. time: this.detail.signdate || '',
  138. }
  139. form.push({
  140. label: "签到",
  141. type: 'location',//类型
  142. key: "location",
  143. value: {},
  144. required: workpresetjson.positioncheck == 11,//是否必填
  145. });
  146. }
  147. if (workpresetjson.paramcheck !== 0) form.push({
  148. label: "设备点位",
  149. type: 'route',//类型
  150. disabled: false,
  151. path: "/select/points",
  152. showKey: "paramname",
  153. idKey: 'w_dataparamid',
  154. param: {
  155. "id": 20230613091602,
  156. "content": {
  157. "ownertable": "w_device",
  158. "ownerid": this.w_deviceid,
  159. "where": { "condition": "" }
  160. }
  161. },
  162. key: "params",
  163. value: {
  164. value: [],
  165. showList: []
  166. },
  167. required: workpresetjson.paramcheck == 11,
  168. });
  169. form.push({
  170. label: "备注",
  171. disabled: false,//禁用
  172. type: 'textarea',//类型
  173. placeholder: "",
  174. value: "",
  175. key: 'remarks',
  176. maxlength: -1,//最大长度
  177. required: false,//是否必填
  178. });
  179. this.$refs.My_form.render(form, this.detail)
  180. })
  181. },
  182. submit(isconfirm) {
  183. let content = {
  184. "sa_workorderid": this.sa_workorderid,
  185. "sa_workorder_nodeid": this.sa_workorder_nodeid,
  186. isconfirm,
  187. ...this.$refs.My_form.onSubmit()
  188. }
  189. content = Object.assign(content, content.location);
  190. content.signdate = content.time || '';
  191. content.params = [content.params] || [];
  192. delete content.location;
  193. delete content.time;
  194. if (isconfirm == 1) {
  195. this.loading = true;
  196. } else {
  197. this.loading1 = true;
  198. }
  199. 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 => {
  200. console.log("绑定附件回调", s)
  201. delete content.attinfos;
  202. this.$Http.basic({
  203. "id": 20230209094203,
  204. content
  205. }).then(res => {
  206. console.log("保存工序", res)
  207. this.loading = false;
  208. this.loading1 = false;
  209. if (this.cutoff(res.msg, isconfirm == 1 ? '确定完成工序成功' : '保存成功')) return;
  210. this.getDetail(true)
  211. console.log(this.$Http)
  212. this.$Http.updateNodes && this.$Http.updateNodes(true)
  213. })
  214. })
  215. },
  216. onConfirm(bool) {
  217. this.disabled = bool;
  218. }
  219. },
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .header {
  224. position: relative;
  225. padding: 10px;
  226. width: 355px;
  227. margin: 10px auto;
  228. background: #fff;
  229. border-radius: 4px;
  230. box-sizing: border-box;
  231. .title {
  232. font-size: 16px;
  233. font-weight: bold;
  234. }
  235. .detail-result {
  236. margin-top: 4px;
  237. display: flex;
  238. align-items: center;
  239. .have-not-begun {
  240. background: #E34D59;
  241. }
  242. .done {
  243. background: #4BA574;
  244. }
  245. .underway {
  246. background: #2151D1;
  247. }
  248. .tag {
  249. font-size: 10px;
  250. padding: 4px;
  251. border-radius: 4px;
  252. color: #fff;
  253. margin-right: 6px;
  254. }
  255. .time {
  256. font-size: 14px;
  257. color: #999;
  258. margin-right: 6px;
  259. }
  260. }
  261. }
  262. .but-box {
  263. width: 355px;
  264. margin: 20px auto 0;
  265. /deep/ .u-button__text,
  266. /deep/.u-button__loading-text {
  267. font-size: 14px !important;
  268. font-weight: bold;
  269. }
  270. /deep/.u-loading-icon__spinner {
  271. width: 17.25px !important;
  272. height: 17.25px !important;
  273. }
  274. }
  275. </style>