index.vue 39 KB

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