accessory.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 readonly 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.executeGroupName">
  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.executeUserId"
  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="请输入内容" v-model="form.purpose"></u--textarea>
  53. </view>
  54. </u-cell>
  55. </u-cell-group>
  56. <accessoryList :itemList="tableList" v-show="current == 1" />
  57. <view class="footerButton">
  58. <u-button type="default" text="返回" @click="back"></u-button>
  59. <u-button type="primary" @click="save" text="保存"></u-button>
  60. </view>
  61. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
  62. valueKey="id" textKey="name" childrenKey="children" />
  63. <u-toast ref="uToast"></u-toast>
  64. </view>
  65. </template>
  66. <script>
  67. import accessoryList from './accessoryList.vue';
  68. import {
  69. getByCode
  70. } from '@/api/pda/common.js'
  71. import {
  72. listOrganizations,
  73. getUserPage
  74. } from '@/api/myTicket/index.js'
  75. import {
  76. getSalesWorkOrderById,
  77. saveOrUpdateSalesWorkOrder
  78. } from '@/api/salesServiceManagement/workOrder/index.js'
  79. export default {
  80. components: {
  81. accessoryList
  82. },
  83. computed: {
  84. },
  85. data() {
  86. return {
  87. current: 0,
  88. type: 'edit',
  89. form: {
  90. name: '',
  91. receivingDeptName: '',
  92. receivingDeptId: '',
  93. recipientName: '',
  94. recipientId: '',
  95. purpose: '',
  96. executeGroupId: '',
  97. executeGroupName: '',
  98. executeUserName: '',
  99. executeUserId: '',
  100. usageTime: ''
  101. },
  102. Usertype: '',
  103. list: ['基本信息', '配件信息'],
  104. listData: [], // 部门数据
  105. userList: [], // 执行人列表
  106. tableList: [], // 配件列表
  107. }
  108. },
  109. onLoad(params) {
  110. this.type = params.type;
  111. this.title = params.type == 'view' ? '工单详情' : '修改工单';
  112. this.getDetails(params.id);
  113. },
  114. onUnload() {},
  115. created() {},
  116. methods: {
  117. async getDetails(id) {
  118. let data = await getSalesWorkOrderById(id);
  119. this.tableList = data.costListVOS.filter((item) => {
  120. if (item.typeId == 2 && item.isApply != 1) {
  121. item.totalPrice = item.settlementPrice;
  122. item.categoryCode = item.code;
  123. item.categoryName = item.name;
  124. return item;
  125. }
  126. })
  127. this.form.receivingDeptName = data.executeGroupName;
  128. this.form.receivingDeptId = data.executeGroupId;
  129. this.form.recipientName = data.executeUserName;
  130. this.form.recipientId = data.executeUserId;
  131. this.form.name = data.name;
  132. this.form.id = data.id;
  133. console.log(this.tableList, 'data ---- 1 + 1')
  134. this.getDept();
  135. },
  136. getDept() {
  137. listOrganizations(1).then(data => {
  138. this.listData = data;
  139. })
  140. },
  141. confirm(data, name) {
  142. this.form.executeGroupName = name
  143. this.form.executeGroupId = data[0]
  144. this.form.executeUserName = ''
  145. this.form.executeUserId = ''
  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.executeUserName = 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.executeGroupName){
  181. this.$refs.uToast.show({
  182. type: "warning",
  183. message: "请选择部门",
  184. })
  185. return;
  186. }
  187. if(!this.form.executeUserName){
  188. this.$refs.uToast.show({
  189. type: "warning",
  190. message: "请选择执行人",
  191. })
  192. return;
  193. }
  194. console.log(this.form,'form --- ===')
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. /deep/.u-subsection__item__text {
  201. font-size: 28rpx !important;
  202. }
  203. /deep/.u-cell__body__content {
  204. flex: none;
  205. margin-right: 16rpx;
  206. }
  207. /deep/ .time_select .uni-data-tree-input {
  208. width: 200rpx;
  209. }
  210. /deep/ .executor_user {
  211. background: #fff;
  212. }
  213. .footerButton {
  214. width: 100%;
  215. height: 84rpx;
  216. display: flex;
  217. position: fixed;
  218. bottom: 0;
  219. z-index: 10;
  220. /deep/.u-button {
  221. height: 100%;
  222. }
  223. >view {
  224. flex: 1;
  225. }
  226. }
  227. </style>