index.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title+'-列表', essential: true }]">
  3. <template slot-scope="{activeKey, data}">
  4. <template-page v-if="activeKey == 'list'" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  5. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  6. :operation="operation()" :exportList="exportList">
  7. <div slot="moreSearch">
  8. <el-radio-group v-model="examineStatus" size="mini" @change="changeType">
  9. <el-radio-button label="">全部</el-radio-button>
  10. <el-radio-button label="IN">未出库</el-radio-button>
  11. <el-radio-button label="OUT">已出库</el-radio-button>
  12. </el-radio-group>
  13. <br><br>
  14. </div>
  15. </template-page>
  16. <div v-if="~['add', 'edit'].indexOf(activeKey)" style="box-sizing: border-box;padding: 16px;">
  17. <el-form ref="formRef" :model="formData" :rules="formRules" label-position="left" label-width="80px">
  18. <div style="font-weight: 500;">客户信息</div>
  19. <el-divider></el-divider>
  20. <el-row :gutter="20">
  21. <el-col :span="6">
  22. <el-form-item label="所属商户" prop="companyWechatName">
  23. <el-input v-model="formData.companyWechatName" autocomplete="off" placeholder="请输入所属商户" disabled></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-form-item label="销售类型" prop="saleType">
  28. <el-radio-group v-model="formData.saleType" disabled>
  29. <el-radio :label="2">线下销售</el-radio>
  30. </el-radio-group>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="6">
  34. <el-form-item label="订单编号" prop="orderId">
  35. <el-input v-model="formData.orderId" autocomplete="off" placeholder="请输入订单编号"></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="6">
  39. <el-form-item label="工单类型" prop="orderSmallType">
  40. <el-select v-model="formData.orderSmallType" placeholder="请选择">
  41. <el-option
  42. v-for="item in orderTypeList"
  43. :key="item.id"
  44. :label="item.orderSmallTypeText"
  45. :value="item.id">
  46. </el-option>
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="6">
  51. <el-form-item label="工单编号" prop="pgOrderId">
  52. <el-input v-model="formData.pgOrderId" autocomplete="off" placeholder="请输入工单编号"></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6">
  56. <el-form-item label="完工时间" prop="overTime">
  57. <el-date-picker
  58. v-model="formData.overTime"
  59. format="yyyy-MM-dd"
  60. value-format="yyyy-MM-dd"
  61. style="width: 100%;"
  62. type="date"
  63. placeholder="选择日期">
  64. </el-date-picker>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="6">
  68. <el-form-item label="客户名称" prop="userName">
  69. <el-input v-model="formData.userName" autocomplete="off" placeholder="请输入客户名称"></el-input>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="6">
  73. <el-form-item label="客户电话" prop="userPhone">
  74. <el-input v-model="formData.userPhone" autocomplete="off" placeholder="请输入客户电话"></el-input>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="24">
  78. <el-form-item label="客户地址" prop="province" :required="true">
  79. <el-row>
  80. <el-col :span="5" style="margin-right: 12px;">
  81. <el-select v-model="formData.provinceId" placeholder="请选择省" style="width: 100%;" @change="changeProvince">
  82. <el-option
  83. v-for="item in provinceList.map(v => ({ value: v.id, label: v.name }))"
  84. :key="item.value"
  85. :label="item.label"
  86. :value="item.value">
  87. </el-option>
  88. </el-select>
  89. </el-col>
  90. <el-col :span="5" style="margin-right: 12px;">
  91. <el-select v-model="formData.cityId" placeholder="请选择市" style="width: 100%;" @change="changeCity">
  92. <el-option
  93. v-for="item in cityList.map(v => ({ value: v.id, label: v.name }))"
  94. :key="item.value"
  95. :label="item.label"
  96. :value="item.value">
  97. </el-option>
  98. </el-select>
  99. </el-col>
  100. <el-col :span="5" style="margin-right: 12px;">
  101. <el-select v-model="formData.areaId" placeholder="请选择区" style="width: 100%;" @change="changeArea">
  102. <el-option
  103. v-for="item in areaList.map(v => ({ value: v.id, label: v.name }))"
  104. :key="item.value"
  105. :label="item.label"
  106. :value="item.value">
  107. </el-option>
  108. </el-select>
  109. </el-col>
  110. <el-col :span="8">
  111. <el-select v-model="formData.streetId" placeholder="请选择街道" style="width: 100%;" @change="changeStreet">
  112. <el-option
  113. v-for="item in streetList.map(v => ({ value: v.id, label: v.name }))"
  114. :key="item.value"
  115. :label="item.label"
  116. :value="item.value">
  117. </el-option>
  118. </el-select>
  119. </el-col>
  120. </el-row>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="24">
  124. <el-form-item label="" prop="userAddress">
  125. <el-row :gutter="20">
  126. <el-col :span="22">
  127. <el-input type="text" v-model="formData.userAddress" placeholder="详细地址"></el-input>
  128. </el-col>
  129. <el-col :span="2">
  130. <geographicalPosi :formData="formData" @selectPosi="selectAddress"/>
  131. </el-col>
  132. </el-row>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="24">
  136. <el-form-item label="备注" prop="remark">
  137. <el-input type="textarea" v-model="formData.remark" autocomplete="off" placeholder="请输入备注"></el-input>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="24">
  141. <el-form-item label="附件" prop="remark">
  142. <el-upload class="avatar-uploader" style="height:122px" :action="baseURL + 'common/upload'" :headers="myHeaders"
  143. :show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload">
  144. <img v-if="formData.fileUrl" :src="formData.fileUrl" class="avatar">
  145. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  146. </el-upload>
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. </el-form>
  151. <el-tabs v-model="formTabs">
  152. <el-tab-pane label="旧机信息" name="a"></el-tab-pane>
  153. </el-tabs>
  154. <div v-show="formTabs == 'a'">
  155. <div style="margin-top: 30px;">
  156. <el-button type="primary" size="small" @click="addOld()">添加旧机</el-button>
  157. </div>
  158. <el-table
  159. class="specTable"
  160. :data="oldList"
  161. element-loading-text="Loading"
  162. border
  163. highlight-current-row
  164. stripe
  165. style="margin-top: 20px">
  166. <el-table-column align="center" label="大类" prop="mainId" min-width="160">
  167. <template slot-scope="scope">
  168. <el-select
  169. size="small"
  170. v-model="scope.row.mainId"
  171. filterable
  172. placeholder="请选择"
  173. @change="changeMain(scope.$index, scope.row)"
  174. v-if="scope.row.isEdit">
  175. <el-option
  176. v-for="item in mainList"
  177. :key="item.categoryId"
  178. :label="item.name"
  179. :value="item.categoryId">
  180. </el-option>
  181. </el-select>
  182. <div v-else>{{scope.row.mainName}}</div>
  183. </template>
  184. </el-table-column>
  185. <el-table-column align="center" label="小类" prop="smallId" min-width="160">
  186. <template slot-scope="scope">
  187. <el-select
  188. size="small"
  189. v-model="scope.row.smallId"
  190. filterable
  191. placeholder="请选择"
  192. @change="changeSmall(scope.$index, scope.row)"
  193. v-if="scope.row.isEdit">
  194. <el-option
  195. v-for="item in smallList"
  196. :key="item.categoryId"
  197. :label="item.name"
  198. :value="item.categoryId">
  199. </el-option>
  200. </el-select>
  201. <div v-else>{{scope.row.smallName}}</div>
  202. </template>
  203. </el-table-column>
  204. <el-table-column align="center" label="规格型号" prop="specId" min-width="160">
  205. <template slot-scope="scope">
  206. <el-select
  207. size="small"
  208. v-model="scope.row.specId"
  209. placeholder="请选择"
  210. @change="changeSpec(scope.$index, scope.row)"
  211. v-if="scope.row.isEdit">
  212. <el-option
  213. v-for="item in specList"
  214. :key="item.id"
  215. :label="item.dictName"
  216. :value="item.id">
  217. </el-option>
  218. </el-select>
  219. <div v-else>{{scope.row.specName}}</div>
  220. </template>
  221. </el-table-column>
  222. <el-table-column align="center" label="属性" prop="attrId" min-width="160">
  223. <template slot-scope="scope">
  224. <el-select
  225. size="small"
  226. v-model="scope.row.attrId"
  227. multiple
  228. placeholder="请选择"
  229. @change="changeAttr(scope.$index, scope.row)"
  230. v-if="scope.row.isEdit">
  231. <el-option
  232. v-for="item in attrList"
  233. :key="item.id"
  234. :label="item.dictName"
  235. :value="item.id"
  236. :disabled="panduanduoxuandanxuan(attrList, item, scope.row.attrId) && !~scope.row.attrId.indexOf(item.id)">
  237. {{ `${item.categoryName} - ${item.dictName}` }}
  238. </el-option>
  239. </el-select>
  240. <div v-else>{{scope.row.attrName.join('、')}}</div>
  241. </template>
  242. </el-table-column>
  243. <el-table-column align="center" label="单位" min-width="120">
  244. <template>台</template>
  245. </el-table-column>
  246. <el-table-column align="center" label="数量" prop="num" min-width="120">
  247. <template slot-scope="scope">
  248. <el-input size="small" v-model="scope.row.num" v-if="scope.row.isEdit"></el-input>
  249. <div v-else>{{scope.row.num}}</div>
  250. </template>
  251. </el-table-column>
  252. <el-table-column align="center" label="金额" prop="payAmount" min-width="120">
  253. <template slot-scope="scope">
  254. <el-input size="small" v-model="scope.row.payAmount" v-if="scope.row.isEdit"></el-input>
  255. <div v-else>{{scope.row.payAmount}}</div>
  256. </template>
  257. </el-table-column>
  258. <el-table-column align="center" label="操作" min-width="120" fixed="right">
  259. <template slot-scope="scope">
  260. <el-button type="text" @click="saveOld(scope.$index, scope.row)" v-if="scope.row.isEdit">保存</el-button>
  261. <el-button type="text" @click="editOld(scope.$index, scope.row)" v-else>编辑</el-button>
  262. <el-popconfirm title="确定删除吗?" @confirm="deleteOld(scope.$index)" style="margin-left: 10px">
  263. <el-button slot="reference" type="text">删除</el-button>
  264. </el-popconfirm>
  265. </template>
  266. </el-table-column>
  267. </el-table>
  268. </div>
  269. <div slot="footer" class="dialog-footer" style="margin-top: 20px;">
  270. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  271. <el-button size="mini" @click="formConfirm(data.removeTab)" type="primary">确 定</el-button>
  272. </div>
  273. </div>
  274. <div v-if="~['detail'].indexOf(activeKey)" style="box-sizing: border-box;padding: 16px;">
  275. <div style="font-weight: 500;">客户信息</div>
  276. <el-divider></el-divider>
  277. <el-descriptions border title="" :column="4" :colon="false" labelStyle="width: 8%" contentStyle="width: 17%">
  278. <el-descriptions-item label="所属商户">
  279. {{detailData.companyName}}
  280. </el-descriptions-item>
  281. <el-descriptions-item label="销售类型">
  282. {{{1: '商城销售', 2: '线下销售'}[detailData.saleType]}}
  283. </el-descriptions-item>
  284. <el-descriptions-item label="订单单号">
  285. {{detailData.orderId}}
  286. </el-descriptions-item>
  287. <el-descriptions-item label="工单类型">
  288. {{detailData.orderSmallTypeText}}
  289. </el-descriptions-item>
  290. </el-descriptions>
  291. <el-descriptions border title="" :column="4" :colon="false" labelStyle="width: 8%" contentStyle="width: 17%" style="margin-top: -1px">
  292. <el-descriptions-item label="订单单号">
  293. {{detailData.pgOrderId}}
  294. </el-descriptions-item>
  295. <el-descriptions-item label="完工时间">
  296. {{detailData.overTime}}
  297. </el-descriptions-item>
  298. <el-descriptions-item label="客户姓名">
  299. {{detailData.userName}}
  300. </el-descriptions-item>
  301. <el-descriptions-item label="客户电话">
  302. {{detailData.userPhone}}
  303. </el-descriptions-item>
  304. </el-descriptions>
  305. <el-descriptions border title="" :column="1" :colon="false" labelStyle="width: 8%" contentStyle="width: 92%" style="margin-top: -1px">
  306. <el-descriptions-item label="详细地址">
  307. {{detailData.province}}{{detailData.city}}{{detailData.area}}{{detailData.street}}{{detailData.userAddress}}
  308. </el-descriptions-item>
  309. </el-descriptions>
  310. <el-descriptions border title="" :column="1" :colon="false" labelStyle="width: 8%" contentStyle="width: 92%" style="margin-top: -1px">
  311. <el-descriptions-item label="附件">
  312. <el-image
  313. v-if="detailData.fileUrl"
  314. style="width: 100px; height: 100px"
  315. :src="detailData.fileUrl"
  316. :preview-src-list="[detailData.fileUrl]">
  317. </el-image>
  318. </el-descriptions-item>
  319. <el-descriptions-item label="备注">
  320. {{detailData.remark}}
  321. </el-descriptions-item>
  322. </el-descriptions>
  323. <el-tabs v-model="detailTabs" style="margin-top: 30px;">
  324. <el-tab-pane label="旧机信息" name="a"></el-tab-pane>
  325. </el-tabs>
  326. <div v-show="detailTabs == 'a'">
  327. <el-table
  328. class="specTable"
  329. :data="detailData.itemList"
  330. element-loading-text="Loading"
  331. border
  332. highlight-current-row
  333. stripe
  334. style="margin-top: 20px">
  335. <el-table-column align="center" label="大类" prop="mainName" min-width="160"></el-table-column>
  336. <el-table-column align="center" label="小类" prop="smallName" min-width="160"></el-table-column>
  337. <el-table-column align="center" label="规格型号" prop="specName" min-width="160"></el-table-column>
  338. <el-table-column align="center" label="属性" prop="attrId" min-width="160">
  339. <template slot-scope="scope">
  340. {{scope.row.oldProductManagerItemAttributes.map(o => o.dictName).join('、')}}
  341. </template>
  342. </el-table-column>
  343. <el-table-column align="center" label="单位" min-width="120">
  344. <template>台</template>
  345. </el-table-column>
  346. <el-table-column align="center" label="数量" prop="num" min-width="120"></el-table-column>
  347. <el-table-column align="center" label="金额" prop="payAmount" min-width="120"></el-table-column>
  348. </el-table>
  349. </div>
  350. <div slot="footer" class="dialog-footer" style="margin-top: 20px;">
  351. <el-button size="mini" @click="data.removeTab()">关 闭</el-button>
  352. </div>
  353. </div>
  354. </template>
  355. </zj-tab-page>
  356. </template>
  357. <script>
  358. import { mapGetters } from 'vuex'
  359. import { getToken } from '@/utils/auth'
  360. import { lbsAmapRegion } from '@/api/common.js'
  361. import TemplatePage from '@/components/template/template-page-1.vue'
  362. import import_mixin from '@/components/template/import_mixin.js'
  363. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  364. import {getList,
  365. listExport,
  366. addData,
  367. editData,
  368. getDetail,
  369. outData,
  370. getOrderTypeList,
  371. getCategoryList,
  372. getAttrList,
  373. } from "@/api/old_machine";
  374. import operation_mixin from '@/components/template/operation_mixin.js'
  375. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  376. export default {
  377. components: { TemplatePage, geographicalPosi },
  378. mixins: [import_mixin,operation_mixin],
  379. data() {
  380. const validatePhone = (rule, value, callback) => {
  381. if(!value) {
  382. callback('请输入手机号')
  383. } else if(!(/^1[3456789]\d{9}$/.test(value))) {
  384. callback('请输入正确的手机号')
  385. } else {
  386. callback()
  387. }
  388. }
  389. return {
  390. baseURL: process.env.VUE_APP_BASE_API,
  391. myHeaders: { 'x-token': getToken() },
  392. // 表格属性
  393. tableAttributes: {
  394. // 启用勾选列
  395. selectColumn: true
  396. },
  397. // 表格事件
  398. tableEvents: {
  399. 'selection-change': this.selectionChange
  400. },
  401. // 勾选选中行
  402. recordSelected: [],
  403. /** 表单变量 */
  404. formDialogType: 0,
  405. formDialogTitles: ["新增", "编辑"],
  406. formDialog: false,
  407. formData: {
  408. id: '',
  409. companyWechatName: '', // 所属商户
  410. saleType: 2, // 销售类型
  411. orderId: '', // 订单编号
  412. orderSmallType: '', // 工单类型
  413. pgOrderId: '', // 工单编号
  414. overTime: '', // 完工时间
  415. userName: '', // 客户名称
  416. userPhone: '', // 客户电话
  417. lng: '',
  418. lat: '',
  419. province: '',
  420. provinceId: '',
  421. city: '',
  422. cityId: '',
  423. area: '',
  424. areaId: '',
  425. street: '',
  426. streetId: '',
  427. userAddress: '',
  428. remark: '', // 备注
  429. fileUrl: '', // 附件
  430. },
  431. formRules: {
  432. userName: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
  433. userPhone: [{ required: true, validator: validatePhone, trigger: 'blur' }],
  434. },
  435. formType: 'add',
  436. formVisible: false,
  437. examineStatus: '',
  438. orderTypeList: [],
  439. provinceList: [],
  440. cityList: [],
  441. areaList: [],
  442. streetList: [],
  443. goodsList: [],
  444. goodsSpecList: [],
  445. goodsSelectList: [],
  446. detailData: {},
  447. examineFormData: {
  448. status: '',
  449. remark: '',
  450. },
  451. examineFormRules: {
  452. status: [{ required: true, message: '请选择审批结果', trigger: 'change' }],
  453. remark: [{ required: true, message: '请输入审批备注', trigger: 'blur' }],
  454. },
  455. showCodeDialog: false,
  456. timer: '',
  457. pageType: '',
  458. formTabs: 'a',
  459. detailTabs: 'a',
  460. oldList: [], // 旧机列表
  461. mainList: [],
  462. smallList: [],
  463. specList: [],
  464. attrList: [],
  465. }
  466. },
  467. computed: {
  468. ...mapGetters(['name']),
  469. // 事件组合
  470. optionsEvensGroup() {
  471. return [
  472. [
  473. [
  474. this.optionsEvensAuth("add", {
  475. click: () => {
  476. this.openForm('add')
  477. }
  478. })
  479. ],
  480. ],
  481. [
  482. [
  483. this.optionsEvensAuth('out', {
  484. name: '批量出库',
  485. click: () => {
  486. this.batchOut()
  487. }
  488. })
  489. ]
  490. ]
  491. ]
  492. },
  493. // 更多参数
  494. moreParameters() {
  495. return []
  496. },
  497. },
  498. create() {
  499. },
  500. methods: {
  501. // 列表请求函数
  502. // getList: getList,
  503. getList(p) {
  504. try {
  505. var pam = JSON.parse(JSON.stringify(p))
  506. if (this.examineStatus) {
  507. pam.params.push({ "param": "a.status", "compare": "=", "value": this.examineStatus })
  508. }
  509. return getList(pam)
  510. } catch (error) {
  511. console.log(error)
  512. }
  513. },
  514. // 列表导出函数
  515. exportList: listExport,
  516. // 表格列解析渲染数据更改
  517. columnParsing(item, defaultData) {
  518. return defaultData
  519. },
  520. // 监听勾选变化
  521. selectionChange(data) {
  522. this.recordSelected = data
  523. },
  524. // 切换状态
  525. changeType(val) {
  526. this.$refs.pageRef.refreshList()
  527. },
  528. // 表格操作列
  529. operation() {
  530. return this.operationBtn({
  531. edit: {
  532. // conditions: ({ row, index, column }) => {
  533. // return row.examineStatus != 'OK'
  534. // },
  535. btnType: 'text',
  536. click: ({ row, index, column }) => {
  537. this.openForm('edit', row.id)
  538. }
  539. },
  540. detail: {
  541. btnType: 'text',
  542. click: ({ row, index, column }) => {
  543. this.openDetail('detail', row.id)
  544. }
  545. },
  546. out: {
  547. conditions: ({ row, index, column }) => {
  548. return row.status == 'IN'
  549. },
  550. btnType: 'text',
  551. prompt: '确定出库吗?',
  552. click: ({ row, index, column }) => {
  553. outData({ oldManagerId: row.id }).then(() => {
  554. this.$message({ type: 'success', message: '出库成功!' })
  555. this.$refs.pageRef.refreshList()
  556. })
  557. }
  558. },
  559. })
  560. },
  561. openForm(type, id) {
  562. this.$refs.tabPage.addTab({
  563. // 对应显示的模块
  564. activeKey: type,
  565. // 唯一标识
  566. key: type,
  567. // 页签名称
  568. label: ({ add: '新增', edit: '编辑' })[type],
  569. // 打开时事件
  570. triggerEvent: () => {
  571. this.pageType = type;
  572. this.formCancel()
  573. this.$nextTick(()=>{
  574. this.getOrderTypeList();
  575. this.formType = type;
  576. this.formVisible = true;
  577. if (type == 'add') {
  578. this.formDialogType = 0
  579. this.formData.companyWechatName = this.name;
  580. this.getinitlbslist();
  581. } else if(type == 'edit'){
  582. this.formDialogType = 1;
  583. getDetail({ oldManagerId: id }).then(res => {
  584. const data = res.data;
  585. this.formData = Object.keys(this.formData).reduce((result, key) => {
  586. if (data.hasOwnProperty(key)) {
  587. result[key] = data[key];
  588. }else {
  589. result[key] = this.formData[key];
  590. }
  591. return result;
  592. }, {});
  593. if(data.itemList?.length > 0) {
  594. this.oldList = data.itemList.map(item => {
  595. return {
  596. isEdit: false,
  597. mainId: item.mainId,
  598. mainName: item.mainName,
  599. smallId: item.smallId,
  600. smallName: item.smallName,
  601. specId: item.specId,
  602. specName: item.specName,
  603. attrId: item.oldProductManagerItemAttributes.map(o => o.goodsCategoryItemId),
  604. attrName: item.oldProductManagerItemAttributes.map(o => o.dictName),
  605. num: item.num,
  606. payAmount: item.payAmount,
  607. }
  608. })
  609. }
  610. this.getinitlbslist();
  611. })
  612. }
  613. })
  614. },
  615. // 关闭时事件
  616. closeEvent: () => {
  617. this.formCancel()
  618. }
  619. })
  620. },
  621. formCancel() {
  622. this.formVisible = false
  623. this.$refs?.formRef?.resetFields()
  624. this.formData.id = '';
  625. this.formData.province = '';
  626. this.formData.provinceId = '';
  627. this.formData.city = '';
  628. this.formData.cityId = '';
  629. this.formData.area = '';
  630. this.formData.areaId = '';
  631. this.formData.street = '';
  632. this.formData.streetId = '';
  633. this.formData.fileUrl = '';
  634. this.oldList = [];
  635. this.$data.formRef = this.$options.data().formRef
  636. },
  637. formConfirm(cancel) {
  638. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  639. if (valid) {
  640. if(this.oldList.some(o => o.isEdit)) return this.$errorMsg('旧机信息存在未保存信息');
  641. let orderSmallTypeText = this.orderTypeList.find(o => o.id == this.formData.orderSmallType).orderSmallTypeText;
  642. let oldList = this.oldList.map(item => {
  643. return {
  644. id: item.specId,
  645. itemIds: item.attrId,
  646. num: item.num,
  647. payAmount: item.payAmount
  648. }
  649. })
  650. if(this.formDialogType == 0) {
  651. addData({
  652. ...this.formData,
  653. overTime: this.formData.overTime.length == 10 ? this.formData.overTime + ' 00:00:00' : this.formData.overTime,
  654. orderSmallTypeText,
  655. orderOldProductAdds: oldList
  656. }).then(res => {
  657. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  658. cancel('list')
  659. this.$refs.pageRef.refreshList()
  660. })
  661. }else {
  662. editData({
  663. ...this.formData,
  664. overTime: this.formData.overTime.length == 10 ? this.formData.overTime + ' 00:00:00' : this.formData.overTime,
  665. orderSmallTypeText,
  666. orderOldProductAdds: oldList
  667. }).then(res => {
  668. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  669. cancel('list')
  670. this.$refs.pageRef.refreshList()
  671. })
  672. }
  673. }
  674. })
  675. },
  676. openDetail(type, id) {
  677. this.$refs.tabPage.addTab({
  678. // 对应显示的模块
  679. activeKey: type,
  680. // 唯一标识
  681. key: type,
  682. // 页签名称
  683. label: ({ detail: '详情' })[type],
  684. // 打开时事件
  685. triggerEvent: () => {
  686. this.pageType = type;
  687. this.formCancel()
  688. this.$nextTick(()=>{
  689. this.detailTabs = 'a';
  690. if (type == 'detail') {
  691. this.formDialogType = 0
  692. }
  693. getDetail({ oldManagerId: id }).then(res => {
  694. this.detailData = res.data;
  695. })
  696. })
  697. },
  698. // 关闭时事件
  699. closeEvent: () => {
  700. this.detailCancel()
  701. }
  702. })
  703. },
  704. detailCancel() {
  705. this.formVisible = false
  706. this.$refs?.examineForm?.resetFields()
  707. this.$data.examineForm = this.$options.data().examineForm
  708. },
  709. detailConfirm(cancel) {
  710. this.$refs.examineForm.validate((valid, invalidFields, errLabels) => {
  711. if (valid) {
  712. outData({
  713. orderId: this.detailData.orderId,
  714. examineStatus: this.examineFormData.status,
  715. examineRemark: this.examineFormData.remark,
  716. }).then(res => {
  717. if(this.examineFormData.status == 'OK' && res.data.codeUrl) {
  718. this.creatCode(res.data.codeUrl, this.detailData.orderId);
  719. }else {
  720. this.$message({ type: 'success', message: `审批成功!` })
  721. cancel('list')
  722. this.$refs.pageRef.refreshList()
  723. }
  724. })
  725. }
  726. })
  727. },
  728. // 附件 - 上传成功
  729. uploadSuccess(res, file) {
  730. this.formData.fileUrl = res.data.url;
  731. },
  732. // 附件 - 上传前
  733. beforeUpload(file) {
  734. const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
  735. const whiteList = ['jpg', 'jpeg', 'png'];
  736. if (whiteList.indexOf(fileSuffix) === -1) {
  737. this.$errorMsg('只支持上传jpg/png文件!');
  738. return false;
  739. }
  740. },
  741. getinitlbslist() {
  742. // 初始化请求省市区街道下拉选项数据
  743. lbsAmapRegion({ pid: 0 }).then(res => {
  744. this.provinceList = res.data
  745. if (this.formData.province) {
  746. var provinceItem = this.provinceList.find(o => o.name === this.formData.province)
  747. if (provinceItem) {
  748. this.formData.provinceId = provinceItem.id
  749. }
  750. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  751. this.cityList = res.data
  752. if (this.formData.city) {
  753. var cityItem = this.cityList.find(o => o.name === this.formData.city)
  754. if (cityItem) {
  755. this.formData.cityId = cityItem.id
  756. }
  757. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  758. this.areaList = res.data
  759. if (this.formData.area) {
  760. var areaItem = this.areaList.find(o => o.name === this.formData.area)
  761. if (areaItem) {
  762. this.formData.areaId = areaItem.id
  763. }
  764. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  765. this.streetList = res.data
  766. if (this.formData.street) {
  767. var streetItem = this.streetList.find(o => o.name === this.formData.street)
  768. if (streetItem) {
  769. this.formData.streetId = streetItem.id
  770. }
  771. }
  772. })
  773. }
  774. })
  775. }
  776. })
  777. }
  778. })
  779. },
  780. delDataK(num) {
  781. if (num <= 1) {
  782. // 删除市
  783. this.formData.cityId = ''
  784. this.formData.city = ''
  785. // 删除市选项
  786. this.cityList = []
  787. }
  788. if (num <= 2) {
  789. // 删除区
  790. this.formData.areaId = ''
  791. this.formData.area = ''
  792. // 删除区选项
  793. this.areaList = []
  794. }
  795. if (num <= 3) {
  796. // 删除街道
  797. this.formData.streetId = ''
  798. this.formData.street = ''
  799. // 删除街道选项
  800. this.streetList = []
  801. }
  802. // 删除gps地址
  803. this.formData.gpsAddress = ''
  804. },
  805. // 更改省
  806. changeProvince(val) {
  807. // 获取省名称
  808. this.formData.province = this.provinceList.find(item => item.id === val)?.name || ''
  809. // 清除市区街道以及详细地址数据
  810. this.delDataK(1)
  811. lbsAmapRegion({ pid: val }).then(res => {
  812. this.cityList = res.data
  813. })
  814. },
  815. // 更改市
  816. changeCity(val) {
  817. // 获取市名称
  818. this.formData.city = this.cityList.find(item => item.id === val).name
  819. // 清除区街道以及详细地址数据
  820. this.delDataK(2)
  821. lbsAmapRegion({ pid: val }).then(res => {
  822. this.areaList = res.data
  823. })
  824. },
  825. // 更改区
  826. changeArea(val) {
  827. // 获取区名称
  828. this.formData.area = this.areaList.find(item => item.id === val).name
  829. // 清除街道以及详细地址数据
  830. this.delDataK(3)
  831. lbsAmapRegion({ pid: val }).then(res => {
  832. this.streetList = res.data
  833. })
  834. },
  835. // 更改街道
  836. changeStreet(val) {
  837. // 获取街道名称
  838. this.formData.street = this.streetList.find(item => item.id === val).name
  839. // 清除详细地址数据
  840. this.delDataK(4)
  841. },
  842. selectAddress(data){
  843. console.log(data);
  844. this.formData.lng = data.center[0]
  845. this.formData.lat = data.center[1]
  846. // 获取定位的省市区街道
  847. var { province, city, district, township } = data.data.addressComponent
  848. // 获取选中省名称id
  849. var { id, name } = this.provinceList.find(item => item.name === province)
  850. this.formData.provinceId = id
  851. this.formData.province = name
  852. // 请求市选项
  853. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  854. // 赋值市选项
  855. this.cityList = res.data
  856. // 获取选中市名称id
  857. var { id, name } = res.data.find(item => item.name === city)
  858. this.formData.cityId = id
  859. this.formData.city = name
  860. // 请求区选项
  861. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  862. // 赋值区选项
  863. this.areaList = res.data
  864. // 获取选中区名称id
  865. var { id, name } = res.data.find(item => item.name === district)
  866. this.formData.areaId = id
  867. this.formData.area = name
  868. // 请求街道选项
  869. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  870. // 赋值街道选项
  871. this.streetList = res.data
  872. // 获取选中街道名称id
  873. var { id, name } = res.data.find(item => item.name === township)
  874. this.formData.streetId = id
  875. this.formData.street = name
  876. // 赋值GPS详细地址
  877. this.formData.userAddress = data.name
  878. })
  879. })
  880. })
  881. },
  882. batchOut() {
  883. if (this.recordSelected && this.recordSelected.length > 0) {
  884. let ids = []
  885. this.recordSelected.forEach(value => {
  886. ids.push(value.id)
  887. })
  888. outData({oldManagerId: ids.join(',')}).then(() => {
  889. this.$message({ type: 'success', message: '出库成功!' })
  890. this.$refs.pageRef.refreshList()
  891. })
  892. } else {
  893. this.$errorMsg('请选择')
  894. }
  895. },
  896. // 获取工单类型列表
  897. getOrderTypeList() {
  898. getOrderTypeList({
  899. pageNum: 1,
  900. pageSize: -1,
  901. params: [{param: "a.status", compare: "=", value: true}]
  902. }).then(res => {
  903. this.orderTypeList = res.data.records;
  904. })
  905. },
  906. // 获取类目列表
  907. getCategoryList() {
  908. return new Promise((resolve, reject) => {
  909. getCategoryList().then(res => {
  910. this.mainList = res.data;
  911. resolve(1);
  912. })
  913. })
  914. },
  915. // 获取规格/属性列表
  916. getAttrList(smallId) {
  917. getAttrList({
  918. pageNum: 1,
  919. pageSize: -1,
  920. params: [
  921. {param: 'small_id', compare: '=', value: smallId},
  922. {param: 'status', compare: '=', value: 'ON'}
  923. ]
  924. }).then(res => {
  925. this.specList = res.data.records.filter(o => o.typeAttribute == 'SPEC');
  926. this.attrList = res.data.records.filter(o => o.typeAttribute == 'OTHER');
  927. })
  928. },
  929. panduanduoxuandanxuan(list, data, vals) {
  930. if (data.typeOption === "SIGIN") {
  931. return !!list.filter(item => !!~vals.indexOf(item.id) && item.serviceCategoryId === data.serviceCategoryId).length
  932. } else {
  933. return false
  934. }
  935. },
  936. // 添加旧机
  937. addOld() {
  938. if(this.oldList.some(o => o.isEdit)) return this.$errorMsg('旧机信息存在未保存信息');
  939. this.getCategoryList();
  940. let obj = {
  941. isEdit: true,
  942. mainId: '',
  943. mainName: '',
  944. smallId: '',
  945. smallName: '',
  946. specId: '',
  947. specName: '',
  948. attrId: [],
  949. attrName: [],
  950. num: '',
  951. payAmount: '',
  952. }
  953. let item = JSON.parse(JSON.stringify(obj));
  954. this.oldList.push(item);
  955. },
  956. // 编辑旧机
  957. async editOld(index, row) {
  958. if(this.oldList.some(o => o.isEdit)) return this.$errorMsg('旧机信息存在未保存信息');
  959. this.oldList[index].isEdit = true;
  960. await this.getCategoryList();
  961. this.smallList = this.mainList.find(o => o.categoryId == row.mainId).children;
  962. this.getAttrList(row.smallId);
  963. },
  964. // 保存旧机
  965. saveOld(index) {
  966. const data = this.oldList[index];
  967. if(!data.mainId) return this.$errorMsg('请选择大类');
  968. if(!data.smallId) return this.$errorMsg('请选择小类');
  969. if(!data.specId) return this.$errorMsg('请选择规格型号');
  970. if(!data.num) return this.$errorMsg('请输入数量');
  971. if(!data.payAmount) return this.$errorMsg('请输入金额');
  972. this.oldList[index].isEdit = false;
  973. this.mainList = [];
  974. this.smallList = [];
  975. this.specList = [];
  976. this.attrList = [];
  977. },
  978. // 删除旧机
  979. deleteOld(index) {
  980. this.oldList.splice(index, 1);
  981. },
  982. // 切换大类
  983. changeMain(index, row) {
  984. this.oldList[index].mainName = this.mainList.find(o => o.categoryId == row.mainId).name;
  985. this.smallList = this.mainList.find(o => o.categoryId == row.mainId).children;
  986. this.oldList[index].smallId = '';
  987. this.oldList[index].specId = '';
  988. this.oldList[index].attrId = [];
  989. this.specList = [];
  990. this.attrList = [];
  991. },
  992. // 切换小类
  993. changeSmall(index, row) {
  994. this.oldList[index].smallName = this.smallList.find(o => o.categoryId == row.smallId).name;
  995. this.oldList[index].specId = '';
  996. this.oldList[index].attrId = [];
  997. this.specList = [];
  998. this.attrList = [];
  999. this.getAttrList(row.smallId);
  1000. },
  1001. // 切换规格
  1002. changeSpec(index, row) {
  1003. this.oldList[index].specName = this.specList.find(o => o.id == row.specId).dictName;
  1004. },
  1005. // 切换属性
  1006. changeAttr(index, row) {
  1007. let names = [];
  1008. // 遍历对象数组
  1009. this.attrList.forEach(obj => {
  1010. // 如果当前对象的ID在ID数组中
  1011. if (row.attrId.includes(obj.id)) {
  1012. // 将当前对象的name属性添加到names数组中
  1013. names.push(obj.dictName);
  1014. }
  1015. });
  1016. this.oldList[index].attrName = names;
  1017. },
  1018. }
  1019. }
  1020. </script>
  1021. <style lang="scss">
  1022. .specTable .el-table__cell {
  1023. padding: 0 !important;
  1024. }
  1025. // 图片墙
  1026. .el-upload-list--picture-card .el-upload-list__item {
  1027. width: 100px;
  1028. height: 100px;
  1029. }
  1030. .el-upload--picture-card {
  1031. width: 100px;
  1032. height: 100px;
  1033. line-height: 100px;
  1034. .avatar-uploader-icon {
  1035. font-size: 28px;
  1036. color: #8c939d;
  1037. width: 100px;
  1038. height: 100px;
  1039. line-height: 100px;
  1040. text-align: center;
  1041. }
  1042. }
  1043. </style>