setNode.vue 10 KB

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