accessory.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="配件申请"
  4. @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
  7. <u-cell-group v-show="current == 0">
  8. <u-cell title="编码" arrow-direction="down">
  9. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  10. <u--input disabled style="flex:1" border="surround" v-model="form.code">
  11. </u--input>
  12. </view>
  13. </u-cell>
  14. <u-cell title="名称" arrow-direction="down">
  15. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  16. <u--input readonly placeholder="请输入" style="flex:1" border="surround" v-model="form.name">
  17. </u--input>
  18. </view>
  19. </u-cell>
  20. <u-cell title="领用部门" arrow-direction="down">
  21. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  22. <u--input readonly placeholder="请输入" style="flex:1" border="surround"
  23. v-model="form.receivingDeptName">
  24. </u--input>
  25. </view>
  26. </u-cell>
  27. <u-cell title="领用人" arrow-direction="down">
  28. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  29. <u--input readonly placeholder="请输入" style="flex:1" border="surround" v-model="form.recipientName">
  30. </u--input>
  31. </view>
  32. </u-cell>
  33. <u-cell title="使用时间" arrow-direction="down">
  34. <uni-datetime-picker type="datetime" slot="value" v-model="form.usageTime">
  35. </uni-datetime-picker>
  36. </u-cell>
  37. <u-cell title="部门" arrow-direction="down">
  38. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  39. <u--input style="flex:1" placeholder="请选择" border="surround" @click.native="selectDepartment"
  40. v-model="form.useDeptName">
  41. </u--input>
  42. </view>
  43. </u-cell>
  44. <u-cell title="使用人" arrow-direction="down">
  45. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  46. <zxz-uni-data-select class="executor_user" :localdata="userList" v-model="form.userId"
  47. @change="handleUserChange" :multiple="Usertype==2"></zxz-uni-data-select>
  48. </view>
  49. </u-cell>
  50. <u-cell title="用途" arrow-direction="down">
  51. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  52. <u--textarea style="flex:1" border="surround" placeholder="请输入内容"
  53. v-model="form.purpose"></u--textarea>
  54. </view>
  55. </u-cell>
  56. </u-cell-group>
  57. <accessoryList ref="accessoryRef" :itemList="tableList" v-show="current == 1" />
  58. <view class="footerButton">
  59. <u-button type="default" text="返回" @click="back"></u-button>
  60. <u-button type="primary" @click="save" text="保存"></u-button>
  61. </view>
  62. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
  63. valueKey="id" textKey="name" childrenKey="children" />
  64. <u-toast ref="uToast"></u-toast>
  65. </view>
  66. </template>
  67. <script>
  68. import accessoryList from './accessoryList.vue';
  69. import {
  70. getByCode
  71. } from '@/api/pda/common.js'
  72. import {
  73. listOrganizations,
  74. getUserPage
  75. } from '@/api/myTicket/index.js'
  76. import {
  77. getSalesWorkOrderById,
  78. saveOrUpdateSalesWorkOrder
  79. } from '@/api/salesServiceManagement/workOrder/index.js'
  80. export default {
  81. components: {
  82. accessoryList
  83. },
  84. computed: {
  85. },
  86. data() {
  87. return {
  88. current: 0,
  89. type: 'edit',
  90. form: {
  91. name: '',
  92. receivingDeptName: '',
  93. receivingDeptId: '',
  94. recipientName: '',
  95. recipientId: '',
  96. purpose: '',
  97. useDeptId: '',
  98. useDeptName: '',
  99. userName: '',
  100. userId: '',
  101. usageTime: ''
  102. },
  103. Usertype: '',
  104. list: ['基本信息', '配件信息'],
  105. listData: [], // 部门数据
  106. userList: [], // 执行人列表
  107. tableList: [], // 配件列表
  108. }
  109. },
  110. onLoad(params) {
  111. this.type = params.type;
  112. this.title = params.type == 'view' ? '工单详情' : '修改工单';
  113. this.getDetails(params.id);
  114. },
  115. onUnload() {},
  116. created() {},
  117. methods: {
  118. async getDetails(id) {
  119. let data = await getSalesWorkOrderById(id);
  120. this.tableList = data.costListVOS.filter((item) => {
  121. if (item.typeId == 2 && item.isApply != 1) {
  122. item.totalPrice = item.settlementPrice;
  123. item.categoryCode = item.code;
  124. item.categoryName = item.name;
  125. return item;
  126. }
  127. })
  128. this.form.receivingDeptName = data.executeGroupName;
  129. this.form.receivingDeptId = data.executeGroupId;
  130. this.form.recipientName = data.executeUserName;
  131. this.form.recipientId = data.executeUserId;
  132. this.form.name = data.name;
  133. this.form.id = data.id;
  134. this.getDept();
  135. },
  136. getDept() {
  137. listOrganizations(1).then(data => {
  138. this.listData = data;
  139. })
  140. },
  141. confirm(data, name) {
  142. this.form.useDeptName = name
  143. this.form.useDeptId = data[0]
  144. this.form.userName = ''
  145. this.form.userId = ''
  146. this.getUser(data[0])
  147. },
  148. getUser(deptCode) {
  149. getUserPage({
  150. pageNum: 1,
  151. size: -1,
  152. groupId: deptCode
  153. }).then(data => {
  154. this.userList = data.list.map(item => {
  155. item.text = item.name;
  156. item.value = item.id;
  157. return item;
  158. })
  159. })
  160. },
  161. sectionChange(index) {
  162. this.current = index;
  163. },
  164. // 选择部门
  165. selectDepartment() {
  166. this.$refs.treePicker._show();
  167. },
  168. // 选择人
  169. handleUserChange(obj) {
  170. this.form.userName = obj.name;
  171. },
  172. save() {
  173. if (!this.form.usageTime) {
  174. this.$refs.uToast.show({
  175. type: "warning",
  176. message: "请选择使用时间",
  177. })
  178. return;
  179. }
  180. if (!this.form.useDeptName) {
  181. this.$refs.uToast.show({
  182. type: "warning",
  183. message: "请选择部门",
  184. })
  185. return;
  186. }
  187. if (!this.form.userName) {
  188. this.$refs.uToast.show({
  189. type: "warning",
  190. message: "请选择执行人",
  191. })
  192. return;
  193. }
  194. let list = this.$refs.accessoryRef.getTabData();
  195. let form = JSON.parse(JSON.stringify(this.form));
  196. let arr = form.usageTime.split(' ');
  197. if (!arr[1]) {
  198. form.usageTime = form.usageTime + ' 00:00:00'
  199. }
  200. const data = {
  201. ...form,
  202. details: list
  203. }
  204. uni.showLoading({
  205. title: '加载中'
  206. })
  207. saveOrUpdateSalesWorkOrder(data).then((res) => {
  208. this.$refs.uToast.show({
  209. type: "success",
  210. message: "操作成功",
  211. })
  212. uni.hideLoading();
  213. this.back();
  214. }).catch((e) => {
  215. uni.hideLoading();
  216. })
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. /deep/.u-subsection__item__text {
  223. font-size: 28rpx !important;
  224. }
  225. /deep/.u-cell__body__content {
  226. flex: none;
  227. margin-right: 16rpx;
  228. }
  229. /deep/ .time_select .uni-data-tree-input {
  230. width: 200rpx;
  231. }
  232. /deep/ .executor_user {
  233. background: #fff;
  234. }
  235. .footerButton {
  236. width: 100%;
  237. height: 84rpx;
  238. display: flex;
  239. position: fixed;
  240. bottom: 0;
  241. z-index: 10;
  242. /deep/.u-button {
  243. height: 100%;
  244. }
  245. >view {
  246. flex: 1;
  247. }
  248. }
  249. </style>