8e8f5ed2bd82627f3b63fa0b239bbd4d36471a26.svn-base 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <p class="recipeTemplate" />
  6. <div class="operation">
  7. <el-button class="success" @click="handleCreate">新增</el-button>
  8. <el-button class="danger" @click="handleDelete">删除</el-button>
  9. <el-button class="warning" @click="handleCopy">复制</el-button>
  10. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  11. <el-button class="success" @click="handleHistory">生成历史</el-button>
  12. <el-button class="import" style="float: right;margin-right: 80px;" @click="handleImport">导入</el-button>
  13. <el-dropdown style="float: right;margin-right: 10px;">
  14. <el-button class="export">导出</el-button>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  17. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. </div>
  21. <div class="search">
  22. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  23. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  24. </el-select>
  25. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  26. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  27. </el-select>
  28. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  29. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  30. </el-select>
  31. <div ref="selectInput" class="filter-item selectInput">
  32. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  33. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  34. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  35. <ul v-if="arrowUp" class="selectUl">
  36. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  37. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  38. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  39. <li>
  40. <div style="float: right;">
  41. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  42. <el-button class="miniSuccess" @click="handleSearch">搜索</el-button>
  43. </div>
  44. </li>
  45. </ul>
  46. </div>
  47. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  48. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  49. </div>
  50. <div class="table">
  51. <el-table
  52. :key="table.tableKey"
  53. v-loading="table.listLoading"
  54. element-loading-text="给我一点时间"
  55. :data="table.list"
  56. border
  57. fit
  58. highlight-current-row
  59. style="width: 98%;"
  60. :row-style="rowStyle"
  61. :cell-style="cellStyle"
  62. class="elTable table-fixed"
  63. @row-click="tableRowClick"
  64. @selection-change="handleSelectionChange"
  65. >
  66. <el-table-column type="selection" align="center" width="50" />
  67. <el-table-column label="序号" align="center" type="index" width="50px">
  68. <template slot-scope="scope">
  69. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="配方名称" min-width="130px" align="center">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  75. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="配方颜色" min-width="130px" align="center">
  79. <template slot-scope="scope">
  80. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="牲畜类别" min-width="150px" align="center">
  84. <template slot-scope="scope">
  85. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  86. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  87. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  88. </el-select>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="配方类型" min-width="150px" align="center">
  92. <template slot-scope="scope">
  93. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  94. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  95. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  96. </el-select>
  97. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  98. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  99. </el-select>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="来源" min-width="110px" align="center">
  103. <template slot-scope="scope">
  104. <span>{{ scope.row.source }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="备注" min-width="110px" align="center">
  108. <template slot-scope="scope">
  109. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  110. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="是否启用" min-width="110px" align="center">
  114. <template slot-scope="scope">
  115. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  119. <template slot-scope="{row}">
  120. <!-- 新增 -->
  121. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  122. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  123. <!-- 编辑 -->
  124. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  125. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  126. <!-- 编辑保存 -->
  127. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  128. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. </div>
  133. </div>
  134. <!-- 配方详情表 -->
  135. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  136. <p class="recipeDetail" />
  137. <div class="operation">
  138. <el-button class="success" @click="handleCreate2">新增</el-button>
  139. <el-button class="danger" @click="handleDelete2">删除</el-button>
  140. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  141. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  142. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  143. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  144. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  145. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  146. <li>
  147. <a style="width: 130px;">饲料名称</a>
  148. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  149. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  150. </el-select>
  151. </li>
  152. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  153. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  154. <li>
  155. <a style="width: 130px;">搅拌延时</a>
  156. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  157. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  158. </el-select>
  159. </li>
  160. <li>
  161. <a style="width: 130px;">是否锁定牛头数比例</a>
  162. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  163. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  164. </el-select>
  165. </li>
  166. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  167. <li>
  168. <div style="float: right;">
  169. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  170. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  171. </div>
  172. </li>
  173. </ul>
  174. </div>
  175. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  176. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  177. </div>
  178. <div class="table2" style="min-height: 400px;">
  179. <el-table
  180. id="table2"
  181. ref="table2"
  182. :key="table2.tableKey"
  183. v-loading="table2.listLoading"
  184. element-loading-text="给我一点时间"
  185. :data="table2.list"
  186. border
  187. fit
  188. highlight-current-row
  189. style="width: 98%;"
  190. :row-style="rowStyle"
  191. :cell-style="cellStyle"
  192. class="elTable table-fixed"
  193. row-key="id"
  194. show-summary
  195. @selection-change="handleSelectionChange2"
  196. >
  197. <el-table-column type="selection" width="60" />
  198. <el-table-column label="序号" align="center" type="index" width="50px" />
  199. <el-table-column label="饲料组" min-width="110px" align="center">
  200. <template slot-scope="scope">
  201. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  202. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  203. </template>
  204. </el-table-column>
  205. <el-table-column label="饲料名称" min-width="130px" align="center">
  206. <template slot-scope="scope">
  207. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  208. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  209. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  210. </el-select>
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  216. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  220. <template slot-scope="scope">
  221. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  222. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  223. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  224. </el-select>
  225. </template>
  226. </el-table-column>
  227. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  228. <template slot-scope="scope">
  229. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  230. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  231. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  232. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  233. </el-select>
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="顺序666" min-width="100px" align="center">
  237. <template slot-scope="scope">
  238. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  239. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  243. <template slot-scope="{row}">
  244. <!-- 新增 -->
  245. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  246. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  247. <!-- 编辑 -->
  248. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  249. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  250. <!-- 编辑保存 -->
  251. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  252. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  253. <!-- 拆分预混料 -->
  254. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  255. </template>
  256. </el-table-column>
  257. </el-table>
  258. </div>
  259. </div>
  260. <!-- 配方记录 -->
  261. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  262. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  263. <div ref="templateDialog" class="templateDialog">
  264. <p class="recipeTemplate" />
  265. <div class="operation">
  266. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  267. <el-button class="successBorder" @click="handleApplication">应用</el-button>
  268. </div>
  269. <div class="search">
  270. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  271. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  272. </el-select>
  273. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  274. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  275. </el-select>
  276. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  277. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  278. </el-select>
  279. <div ref="selectInput" class="filter-item selectInput">
  280. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  281. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  282. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  283. <ul v-if="arrowUp" class="selectUl">
  284. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  285. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  286. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  287. <li>
  288. <div style="float: right;">
  289. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  290. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  291. </div>
  292. </li>
  293. </ul>
  294. </div>
  295. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  296. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  297. </div>
  298. <div class="table">
  299. <el-table
  300. :key="template.table.tableKey"
  301. v-loading="template.table.listLoading"
  302. element-loading-text="给我一点时间"
  303. :data="template.table.list"
  304. border
  305. fit
  306. highlight-current-row
  307. style="width: 98%;"
  308. :row-style="rowStyle"
  309. :cell-style="cellStyle"
  310. class="elTable table-fixed"
  311. @row-click="tableRowClickDialog"
  312. >
  313. <el-table-column label="序号" align="center" type="index" width="50px">
  314. <template slot-scope="scope">
  315. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  316. </template>
  317. </el-table-column>
  318. <el-table-column label="配方名称" min-width="130px" align="center">
  319. <template slot-scope="scope">
  320. <span>{{ scope.row.tname }}</span>
  321. </template>
  322. </el-table-column>
  323. <el-table-column label="配方颜色" min-width="130px" align="center">
  324. <template slot-scope="scope">
  325. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  326. </template>
  327. </el-table-column>
  328. <el-table-column label="牲畜类别" min-width="150px" align="center">
  329. <template slot-scope="scope">
  330. <span>{{ scope.row.ccname }}</span>
  331. </template>
  332. </el-table-column>
  333. <el-table-column label="配方类型" min-width="150px" align="center">
  334. <template slot-scope="scope">
  335. <span>{{ scope.row.fttype }}</span>
  336. </template>
  337. </el-table-column>
  338. <el-table-column label="来源" min-width="110px" align="center">
  339. <template slot-scope="scope">
  340. <span>{{ scope.row.source }}</span>
  341. </template>
  342. </el-table-column>
  343. <el-table-column label="备注" min-width="110px" align="center">
  344. <template slot-scope="scope">
  345. <span>{{ scope.row.remark }}</span>
  346. </template>
  347. </el-table-column>
  348. <el-table-column label="是否启用" min-width="110px" align="center">
  349. <template slot-scope="scope">
  350. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  351. </template>
  352. </el-table-column>
  353. </el-table>
  354. </div>
  355. </div>
  356. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  357. <p class="recipeDetail" />
  358. <div class="operation">
  359. <div ref="selectInput2" class="filter-item selectInput">
  360. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  361. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  362. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  363. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  364. <li>
  365. <a style="width: 130px;">饲料名称</a>
  366. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  367. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  368. </el-select>
  369. </li>
  370. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  371. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  372. <li>
  373. <a style="width: 130px;">搅拌延时</a>
  374. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  375. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  376. </el-select>
  377. </li>
  378. <li>
  379. <a style="width: 130px;">是否锁定牛头数比例</a>
  380. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  381. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  382. </el-select>
  383. </li>
  384. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  385. <li>
  386. <div style="float: right;">
  387. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  388. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  389. </div>
  390. </li>
  391. </ul>
  392. </div>
  393. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  394. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  395. </div>
  396. <div class="table2">
  397. <el-table
  398. :key="template.table2.tableKey"
  399. v-loading="template.table2.listLoading"
  400. element-loading-text="给我一点时间"
  401. :data="template.table2.list"
  402. border
  403. fit
  404. highlight-current-row
  405. style="width: 98%;"
  406. :row-style="rowStyle"
  407. :cell-style="cellStyle"
  408. class="elTable table-fixed"
  409. row-key="id"
  410. >
  411. <el-table-column label="饲料组" min-width="130px" align="center">
  412. <template slot-scope="scope">
  413. <span>{{ scope.row.feedgroup }}</span>
  414. </template>
  415. </el-table-column>
  416. <el-table-column label="饲料名称" min-width="130px" align="center">
  417. <template slot-scope="scope">
  418. <span>{{ scope.row.fname }}</span>
  419. </template>
  420. </el-table-column>
  421. <el-table-column label="重量(KG)" min-width="130px" align="center">
  422. <template slot-scope="scope">
  423. <span>{{ scope.row.fweight }}</span>
  424. </template>
  425. </el-table-column>
  426. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  427. <template slot-scope="scope">
  428. <span>{{ scope.row.autosecondname }}</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  432. <template slot-scope="scope">
  433. <span v-if="scope.row.islockcount == '0'">否</span>
  434. <span v-if="scope.row.islockcount == '1'">是</span>
  435. </template>
  436. </el-table-column>
  437. <el-table-column label="顺序" min-width="130px" align="center">
  438. <template slot-scope="scope">
  439. <span>{{ scope.row.sort }}</span>
  440. </template>
  441. </el-table-column>
  442. </el-table>
  443. </div>
  444. </div>
  445. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  446. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  447. </div>
  448. </div>
  449. </el-dialog>
  450. <!-- 合成预混料 -->
  451. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  452. <div class="detailDialog">
  453. <h2>饲料</h2>
  454. <div class="table1">
  455. <el-table
  456. :key="detail.tableKey"
  457. v-loading="detail.listLoading"
  458. element-loading-text="给我一点时间"
  459. :data="detail.list"
  460. fit
  461. highlight-current-row
  462. style="width: 100%;"
  463. :row-style="rowStyle"
  464. :cell-style="cellStyle"
  465. class="elTable table-fixed"
  466. show-summary
  467. >
  468. <el-table-column label="序号" align="center" type="index" width="50px" />
  469. <el-table-column label="饲料名称" min-width="130px" align="center">
  470. <template slot-scope="scope">
  471. <span>{{ scope.row.fname }}</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column prop="fweight" label="重量(KG)" />
  475. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  476. <template slot-scope="scope">
  477. <span>{{ scope.row.autosecond }}</span>
  478. </template>
  479. </el-table-column>
  480. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  481. <template slot-scope="scope">
  482. <span v-if="scope.row.islockcount == '0'">否</span>
  483. <span v-if="scope.row.islockcount == '1'">是</span>
  484. </template>
  485. </el-table-column>
  486. <el-table-column label="顺序" min-width="110px" align="center">
  487. <template slot-scope="scope">
  488. <span>{{ scope.row.sort }}</span>
  489. </template>
  490. </el-table-column>
  491. </el-table>
  492. </div>
  493. <h2>合成预混料</h2>
  494. <div class="table2" style="margin-bottom: 50px;">
  495. <el-table
  496. :key="detail.tableKey2"
  497. v-loading="detail.listLoading2"
  498. element-loading-text="给我一点时间"
  499. :data="detail.list2"
  500. border
  501. fit
  502. highlight-current-row
  503. style="width: 100%;"
  504. :row-style="rowStyle"
  505. :cell-style="cellStyle"
  506. class="elTable table-fixed"
  507. >
  508. <el-table-column label="配方名称" min-width="130px" align="center">
  509. <template slot-scope="scope">
  510. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  511. </template>
  512. </el-table-column>
  513. <el-table-column label="配方颜色11" min-width="130px" align="center">
  514. <template slot-scope="scope">
  515. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  516. </template>
  517. </el-table-column>
  518. <el-table-column label="牲畜类别" min-width="130px" align="center">
  519. <template slot-scope="scope">
  520. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  521. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  522. </el-select>
  523. </template>
  524. </el-table-column>
  525. <el-table-column label="配方类型" min-width="110px" align="center">
  526. <template slot-scope="scope">
  527. <span>{{ scope.row.fttype }}</span>
  528. </template>
  529. </el-table-column>
  530. <el-table-column label="来源" min-width="110px" align="center">
  531. <template slot-scope="scope">
  532. <span>{{ scope.row.source }}</span>
  533. </template>
  534. </el-table-column>
  535. <el-table-column label="备注" min-width="130px" align="center">
  536. <template slot-scope="scope">
  537. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  538. </template>
  539. </el-table-column>
  540. <el-table-column label="是否启用" min-width="130px" align="center">
  541. <template slot-scope="scope">
  542. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  543. </template>
  544. </el-table-column>
  545. </el-table>
  546. </div>
  547. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  548. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  549. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  550. </div>
  551. </div>
  552. </el-dialog>
  553. </div>
  554. </template>
  555. <script>
  556. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  557. import Sortable from 'sortablejs'
  558. import { MessageBox } from 'element-ui'
  559. import Cookies from 'js-cookie'
  560. export default {
  561. name: 'RecipeTemplate',
  562. data() {
  563. return {
  564. requestParams: [
  565. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  566. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  567. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  568. ],
  569. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  570. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  571. livestockTypeList: [], // 牲畜类别
  572. formulaTypeList: [], // 配方类型
  573. feedNameList: [], // 饲料名称
  574. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  575. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  576. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  577. arrowDown: true,
  578. arrowUp: false,
  579. table: {
  580. getdataListParm: {
  581. name: 'getFTList',
  582. page: 1,
  583. offset: 1,
  584. pagecount: 30,
  585. returntype: 'Map',
  586. parammaps: {
  587. pastureid: Cookies.get('pastureid'),
  588. tname: '',
  589. ccid: '',
  590. ccname: '',
  591. fttypeid: '',
  592. fttype: '',
  593. remark: '',
  594. enable: ''
  595. }
  596. },
  597. tableKey: 0,
  598. list: [],
  599. total: 0,
  600. listLoading: true,
  601. temp: {}
  602. },
  603. lockCount: {
  604. getdataListParm: {
  605. name: 'getSysoptEnable',
  606. page: 1,
  607. offset: 1,
  608. pagecount: 30,
  609. returntype: 'Map',
  610. parammaps: {
  611. pastureid: Cookies.get('pastureid'),
  612. inforname: 'isLockCount'
  613. }
  614. },
  615. isLockCount: false // 是否显示是否锁定牛头数比例
  616. },
  617. isDetail: false,
  618. arrowDown2: true,
  619. arrowUp2: false,
  620. table2: {
  621. getdataListParm: {
  622. name: 'getFTdetailList',
  623. page: 1,
  624. offset: 1,
  625. pagecount: 10,
  626. returntype: 'Map',
  627. parammaps: {
  628. pastureid: Cookies.get('pastureid'),
  629. fname: '',
  630. feedgroup: '',
  631. fweight: '',
  632. autosecondname: '',
  633. islockcount: '',
  634. sort: ''
  635. }
  636. },
  637. tableKey: 0,
  638. list: [],
  639. total: 0,
  640. listLoading: true,
  641. temp: {}
  642. },
  643. isDetailDialog: false,
  644. template: {
  645. dialogFormVisible: false,
  646. dialogStatus: '',
  647. table: {
  648. getdataListParm: {
  649. name: 'getFTListDate',
  650. page: 1,
  651. offset: 1,
  652. pagecount: 10,
  653. returntype: 'Map',
  654. parammaps: {
  655. pastureid: Cookies.get('pastureid'),
  656. tname: '',
  657. ccid: '',
  658. ccname: '',
  659. fttype: '',
  660. remark: '',
  661. enable: '',
  662. date: '',
  663. source: ''
  664. }
  665. },
  666. tableKey: 0,
  667. total: 0,
  668. listLoading: true,
  669. list: []
  670. },
  671. table2: {
  672. getdataListParm: {
  673. name: 'getFTdetailListDate',
  674. page: 1,
  675. offset: 1,
  676. pagecount: 10,
  677. returntype: 'Map',
  678. parammaps: {
  679. pastureid: Cookies.get('pastureid'),
  680. fname: '',
  681. fweight: '',
  682. islockcount: '',
  683. sort: '',
  684. feedgroup: '',
  685. autosecondname: ''
  686. }
  687. },
  688. tableKey: 0,
  689. total: 0,
  690. listLoading: true,
  691. list: []
  692. },
  693. // 历史日期
  694. getdataDateParm: {
  695. name: 'getFTMaxDate',
  696. page: 1,
  697. offset: 1,
  698. pagecount: 10,
  699. returntype: 'Map',
  700. parammaps: {
  701. pastureid: Cookies.get('pastureid')
  702. }
  703. }
  704. },
  705. detail: {
  706. dialogFormVisible: false,
  707. dialogStatus: '',
  708. tableKey: 0,
  709. total: 0,
  710. listLoading: true,
  711. list: [],
  712. tableKey2: 0,
  713. total2: 0,
  714. listLoading2: false,
  715. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  716. getdataListParm: {
  717. name: 'getFTDetailCompare',
  718. page: 1,
  719. offset: 1,
  720. pagecount: 10,
  721. returntype: 'Map',
  722. parammaps: {}
  723. },
  724. list3: [],
  725. disabled: false,
  726. getdataListParm2: {
  727. name: 'getFTCompare',
  728. page: 1,
  729. offset: 1,
  730. pagecount: 10,
  731. returntype: 'Map',
  732. parammaps: {}
  733. }
  734. },
  735. selectList: [],
  736. selectList2: [],
  737. textMap: {
  738. RecipeRecord: '配方记录',
  739. SyntheticPremix: '合成预混料'
  740. },
  741. requestParam: {},
  742. isokDisable: false,
  743. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  744. cellStyle: { padding: 0 + 'px' },
  745. dropState: false
  746. }
  747. },
  748. mounted() {
  749. document.addEventListener('click', (e) => {
  750. if (this.$refs.selectInput !== undefined) {
  751. if (!this.$refs.selectInput.contains(e.target)) {
  752. this.arrowDown = true
  753. this.arrowUp = false
  754. } else {
  755. this.arrowDown = false
  756. this.arrowUp = true
  757. }
  758. }
  759. if (this.$refs.selectInput2 !== undefined) {
  760. if (!this.$refs.selectInput2.contains(e.target)) {
  761. this.arrowDown2 = true
  762. this.arrowUp2 = false
  763. } else {
  764. this.arrowDown2 = false
  765. this.arrowUp2 = true
  766. }
  767. }
  768. })
  769. },
  770. created() {
  771. this.getList()
  772. this.getDownList()
  773. this.getIsLockCount()
  774. },
  775. methods: {
  776. handleHistory() {
  777. MessageBox.confirm('是否确认生成历史?', {
  778. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  779. }).then(() => {
  780. this.requestParam.name = 'creatFTdate'
  781. this.requestParam.parammaps = {}
  782. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  783. PostDataByName(this.requestParam).then(response => {
  784. console.log('生成历史保存发送参数', this.requestParam)
  785. if (response.msg !== 'fail') {
  786. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  787. } else {
  788. failproccess(response, this.$notify)
  789. }
  790. })
  791. })
  792. },
  793. getDownList() {
  794. GetDataByNames(this.requestParams).then(response => {
  795. this.livestockTypeList = response.data.getDictByName.list
  796. this.formulaTypeList = response.data.getDictByName2.list
  797. this.feedNameList = response.data.getFeedAndPre.list
  798. })
  799. },
  800. // -------------------模板-----------------------------
  801. getList() {
  802. this.table.listLoading = true
  803. GetDataByName(this.table.getdataListParm).then(response => {
  804. console.log('table数据', response.data.list)
  805. if (response.data.list !== null) {
  806. for (let i = 0; i < response.data.list.length; i++) {
  807. this.$set(response.data.list[i], 'Edit', false) // 编辑
  808. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  809. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  810. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  811. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  812. }
  813. this.table.list = response.data.list
  814. this.table.pageNum = response.data.pageNum
  815. this.table.pageSize = response.data.pageSize
  816. this.table.total = response.data.total
  817. } else {
  818. this.table.list = []
  819. }
  820. setTimeout(() => {
  821. this.table.listLoading = false
  822. }, 100)
  823. })
  824. },
  825. handleSearch() {
  826. console.log('点击了查询')
  827. this.table.getdataListParm.offset = 1
  828. this.getList()
  829. this.arrowDown = true
  830. this.arrowUp = false
  831. },
  832. handleRefresh() {
  833. console.log('点击了重置')
  834. this.table.getdataListParm.offset = 1
  835. this.table.getdataListParm.parammaps.ccid = ''
  836. this.table.getdataListParm.parammaps.ccname = ''
  837. this.table.getdataListParm.parammaps.fttype = ''
  838. this.table.getdataListParm.parammaps.tname = ''
  839. this.table.getdataListParm.parammaps.remark = ''
  840. this.table.getdataListParm.parammaps.enable = ''
  841. this.table.getdataListParm.parammaps.source = ''
  842. this.getList()
  843. },
  844. // 模板新增
  845. handleCreate() {
  846. console.log('点击了新增')
  847. // 编辑true/不可编辑false
  848. // 新增操true,编辑false,编辑保存false
  849. for (let i = 0; i < this.table.list.length; i++) {
  850. if (this.table.list[i].Edit === true) {
  851. console.log(123)
  852. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  853. return false
  854. }
  855. }
  856. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  857. console.log(this.table.list)
  858. },
  859. // 畜生类别
  860. changeLivestockType(item) {
  861. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  862. },
  863. // 配方类型
  864. changeFormulaType(item) {
  865. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  866. },
  867. createData(row) {
  868. console.log('点击了新增保存', row)
  869. this.table.temp.tname = row.tname
  870. this.table.temp.tcolor = row.tcolor
  871. this.table.temp.ccid = row.ccid
  872. this.table.temp.ccname = this.table.temp.ccname
  873. this.table.temp.fttype = this.table.temp.fttype
  874. this.table.temp.fttypeid = row.fttypeid
  875. this.table.temp.source = row.source
  876. this.table.temp.remark = row.remark
  877. this.table.temp.enable = row.enable
  878. this.table.temp.pastureid = Cookies.get('pastureid')
  879. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  880. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  881. return false
  882. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  883. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  884. return false
  885. } else if (this.table.temp.tname == '') {
  886. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  887. return false
  888. } else if (this.table.temp.ccid == '') {
  889. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  890. return false
  891. } else if (this.table.temp.fttypeid == '') {
  892. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  893. return false
  894. }
  895. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  896. if (pattern.test(this.table.temp.tname)) {
  897. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  898. return false
  899. }
  900. console.log(this.table.temp)
  901. this.isokDisable = true
  902. setTimeout(() => {
  903. this.isokDisable = false
  904. }, 1000)
  905. this.requestParam.name = 'insertFT'
  906. this.requestParam.parammaps = this.table.temp
  907. PostDataByName(this.requestParam).then(response => {
  908. console.log('新增保存发送参数', this.requestParam)
  909. if (response.msg !== 'fail') {
  910. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  911. this.getList()
  912. } else {
  913. failproccess(response, this.$notify)
  914. }
  915. })
  916. },
  917. createCancel(row) {
  918. console.log('点击了新增取消')
  919. for (let i = 0; i < this.table.list.length; i++) {
  920. if (row.myId === this.table.list[i].myId) {
  921. var listIndex = this.table.list.indexOf(this.table.list[i])
  922. }
  923. if (listIndex > -1) {
  924. this.table.list.splice(listIndex, 1)
  925. return
  926. }
  927. }
  928. },
  929. // 模板编辑
  930. handleUpdate(row) {
  931. for (let i = 0; i < this.table.list.length; i++) {
  932. if (this.table.list[i].Edit == true) {
  933. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  934. return false
  935. }
  936. }
  937. // 编辑true,不可编辑false
  938. row.Edit = true
  939. row.NoEdit = false
  940. // 新增false,编辑false,编辑保存true
  941. row.isCreate = false
  942. row.isUpdate = false
  943. row.isUpdateSave = true
  944. row.ccid = String(row.ccid)
  945. row.fttypeid = String(row.fttypeid)
  946. this.table.temp.ccname = row.ccname
  947. this.table.temp.fttype = row.fttype
  948. },
  949. updateData(row) {
  950. console.log('点击了编辑保存', row)
  951. this.table.temp.tname = row.tname
  952. this.table.temp.tcolor = row.tcolor
  953. this.table.temp.ccid = row.ccid
  954. this.table.temp.fttypeid = row.fttypeid
  955. this.table.temp.source = row.source
  956. this.table.temp.remark = row.remark
  957. this.table.temp.enable = row.enable
  958. this.table.temp.ccname = this.table.temp.ccname
  959. this.table.temp.fttype = this.table.temp.fttype
  960. this.table.temp.pastureid = row.pastureid
  961. this.table.temp.id = row.id
  962. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  963. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  964. return false
  965. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  966. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  967. return false
  968. } else if (this.table.temp.tname == '') {
  969. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  970. return false
  971. } else if (this.table.temp.ccid == '') {
  972. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  973. return false
  974. } else if (this.table.temp.fttypeid == '') {
  975. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  976. return false
  977. }
  978. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  979. if (pattern.test(this.table.temp.tname)) {
  980. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  981. return false
  982. }
  983. console.log(this.table.temp)
  984. this.isokDisable = true
  985. setTimeout(() => {
  986. this.isokDisable = false
  987. }, 1000)
  988. this.requestParam.name = 'updateFT'
  989. this.requestParam.parammaps = this.table.temp
  990. PostDataByName(this.requestParam).then(response => {
  991. console.log('新增保存发送参数', this.requestParam)
  992. if (response.msg !== 'fail') {
  993. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  994. this.getList()
  995. } else {
  996. failproccess(response, this.$notify)
  997. }
  998. })
  999. },
  1000. updateCancel(row) {
  1001. console.log('点击了编辑取消')
  1002. // 编辑false,不可编辑true
  1003. row.Edit = false
  1004. row.NoEdit = true
  1005. // 新增false,编辑true,编辑保存false
  1006. row.isCreate = false
  1007. row.isUpdate = true
  1008. row.isUpdateSave = false
  1009. this.getList()
  1010. },
  1011. // 删除
  1012. handleRowDelete(row) {
  1013. console.log('点击了行内删除')
  1014. MessageBox.confirm('是否确认删除此信息?', {
  1015. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1016. }).then(() => {
  1017. this.requestParam.common = { 'returnmap': '0' }
  1018. this.requestParam.data = []
  1019. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1020. pastureid: row.pastureid,
  1021. id: row.id
  1022. }}
  1023. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1024. pastureid: row.pastureid,
  1025. id: row.id
  1026. }}
  1027. ExecDataByConfig(this.requestParam).then(response => {
  1028. console.log('新增保存发送参数', this.requestParam)
  1029. if (response.msg === 'fail') {
  1030. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1031. } else {
  1032. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1033. this.getList()
  1034. this.isDetail = false
  1035. }
  1036. })
  1037. }).catch(() => {
  1038. this.$message({ type: 'info', message: '已取消删除' })
  1039. })
  1040. },
  1041. handleSelectionChange(val) {
  1042. console.log('勾选数据', val)
  1043. this.selectList = val
  1044. },
  1045. handleDelete() {
  1046. console.log('点击了删除')
  1047. if (this.selectList.length == 0) {
  1048. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1049. } else {
  1050. MessageBox.confirm('是否确认删除此信息?', {
  1051. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1052. }).then(() => {
  1053. console.log(this.selectList)
  1054. this.requestParam.common = { 'returnmap': '0' }
  1055. this.requestParam.data = []
  1056. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1057. this.requestParam.data[0].children = []
  1058. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1059. id: '@insertSpotList.id',
  1060. pastureid: '@insertSpotList.pastureid'
  1061. }}
  1062. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1063. id: '@insertSpotList.id',
  1064. pastureid: '@insertSpotList.pastureid'
  1065. }}
  1066. ExecDataByConfig(this.requestParam).then(response => {
  1067. console.log('删除保存发送参数', this.requestParam)
  1068. if (response.msg === 'fail') {
  1069. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1070. } else {
  1071. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1072. this.getList()
  1073. }
  1074. })
  1075. })
  1076. }
  1077. },
  1078. // 复制
  1079. handleCopy() {
  1080. if (this.selectList.length == 0) {
  1081. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1082. } else {
  1083. MessageBox.confirm('是否确认复制此信息?', {
  1084. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1085. }).then(() => {
  1086. console.log(this.selectList)
  1087. this.requestParam.common = { 'returnmap': '0' }
  1088. this.requestParam.data = []
  1089. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1090. this.requestParam.data[0].children = []
  1091. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1092. ftid: '@insertSpotList.id',
  1093. pastureid: '@insertSpotList.pastureid'
  1094. }}
  1095. ExecDataByConfig(this.requestParam).then(response => {
  1096. console.log('复制保存发送参数', this.requestParam)
  1097. if (response.msg === 'fail') {
  1098. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1099. } else {
  1100. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1101. this.getList()
  1102. }
  1103. })
  1104. })
  1105. }
  1106. },
  1107. // 配方记录
  1108. handleRecipeRecord() {
  1109. console.log('点击了配方记录')
  1110. this.template.dialogStatus = 'RecipeRecord'
  1111. this.template.dialogFormVisible = true
  1112. this.template.table.getdataListParm.parammaps.ccname = ''
  1113. this.template.table.getdataListParm.parammaps.fttype = ''
  1114. this.template.table.getdataListParm.parammaps.enable = ''
  1115. this.template.table.getdataListParm.parammaps.tname = ''
  1116. this.template.table.getdataListParm.parammaps.remark = ''
  1117. this.template.table.getdataListParm.parammaps.source = ''
  1118. this.template.table.getdataListParm.offset = 1
  1119. this.getDateList()
  1120. this.isDetailDialog = false
  1121. },
  1122. // 历史时间
  1123. getDateList() {
  1124. GetDataByName(this.template.getdataDateParm).then(response => {
  1125. console.log('table数据', response.data.list)
  1126. if (response.data.list !== null) {
  1127. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1128. this.getTemplateDialogList()
  1129. } else {
  1130. this.template.table.getdataListParm.parammaps.date = ''
  1131. }
  1132. })
  1133. },
  1134. // 配方记录-模板
  1135. getTemplateDialogList() {
  1136. this.template.table.listLoading = true
  1137. GetDataByName(this.template.table.getdataListParm).then(response => {
  1138. console.log('table数据', response.data.list)
  1139. if (response.data.list !== null) {
  1140. this.template.table.list = response.data.list
  1141. this.template.table.pageNum = response.data.pageNum
  1142. this.template.table.pageSize = response.data.pageSize
  1143. this.template.table.total = response.data.total
  1144. } else {
  1145. this.template.table.list = []
  1146. }
  1147. setTimeout(() => {
  1148. this.template.table.listLoading = false
  1149. }, 100)
  1150. })
  1151. },
  1152. handleDialogSearch() {
  1153. this.template.table.getdataListParm.offset = 1
  1154. this.getTemplateDialogList()
  1155. this.arrowDown = true
  1156. this.arrowUp = false
  1157. },
  1158. handleDialogRefresh() {
  1159. this.template.table.getdataListParm.parammaps.ccname = ''
  1160. this.template.table.getdataListParm.parammaps.fttype = ''
  1161. this.template.table.getdataListParm.parammaps.enable = ''
  1162. this.template.table.getdataListParm.parammaps.tname = ''
  1163. this.template.table.getdataListParm.parammaps.remark = ''
  1164. this.template.table.getdataListParm.parammaps.source = ''
  1165. this.template.table.getdataListParm.offset = 1
  1166. this.getTemplateDialogList()
  1167. },
  1168. // 配方记录-模板行点击
  1169. tableRowClickDialog(row, column, event) {
  1170. console.log('配方记录-模板行点击')
  1171. this.isDetailDialog = true
  1172. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1173. this.getDialogList()
  1174. this.getDownList()
  1175. },
  1176. getDialogList() {
  1177. this.template.table2.listLoading = true
  1178. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1179. console.log('table数据', response.data.list)
  1180. if (response.data.list !== null) {
  1181. this.template.table2.list = response.data.list
  1182. this.template.table2.pageNum = response.data.pageNum
  1183. this.template.table2.pageSize = response.data.pageSize
  1184. this.template.table2.total = response.data.total
  1185. } else {
  1186. this.template.table2.list = []
  1187. }
  1188. setTimeout(() => {
  1189. this.template.table2.listLoading = false
  1190. }, 100)
  1191. })
  1192. },
  1193. handleDialogSearch2() {
  1194. console.log('点击了查询')
  1195. this.arrowDown2 = true
  1196. this.arrowUp2 = false
  1197. this.template.table2.getdataListParm.offset = 1
  1198. this.getDialogList2()
  1199. },
  1200. handleDialogRefresh2() {
  1201. console.log('点击了重置')
  1202. this.template.table2.getdataListParm.parammaps.fname = ''
  1203. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1204. this.template.table2.getdataListParm.parammaps.fweight = ''
  1205. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1206. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1207. this.template.table2.getdataListParm.parammaps.sort = ''
  1208. this.template.table2.getdataListParm.offset = 1
  1209. this.getDialogList2()
  1210. },
  1211. getDialogList2() {
  1212. this.template.table2.listLoading = true
  1213. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1214. console.log('table数据', response.data.list)
  1215. if (response.data.list !== null) {
  1216. this.template.table2.list = response.data.list
  1217. this.template.table2.pageNum = response.data.pageNum
  1218. this.template.table2.pageSize = response.data.pageSize
  1219. this.template.table2.total = response.data.total
  1220. } else {
  1221. this.template.table2.list = []
  1222. }
  1223. this.$nextTick(function() {
  1224. window.scrollTo({
  1225. 'top': this.$refs.templateDialog.clientHeight
  1226. })
  1227. })
  1228. setTimeout(() => {
  1229. this.template.table2.listLoading = false
  1230. }, 100)
  1231. })
  1232. },
  1233. handleImport() {
  1234. console.log('点击了导入')
  1235. },
  1236. // 导出
  1237. handleExport(item) {
  1238. if (item == 1) {
  1239. console.log('点击了导出模板')
  1240. } else {
  1241. console.log('点击了导出数据')
  1242. }
  1243. },
  1244. changeDate() {
  1245. this.getTemplateDialogList()
  1246. },
  1247. // 应用
  1248. handleApplication() {
  1249. console.log('点击了应用')
  1250. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1251. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1252. }).then(() => {
  1253. this.requestParam.name = 'applyFTdate'
  1254. this.requestParam.parammaps = {}
  1255. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1256. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1257. PostDataByName(this.requestParam).then(response => {
  1258. if (response.msg === 'fail') {
  1259. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1260. } else {
  1261. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1262. this.getTemplateDialogList()
  1263. this.getList()
  1264. }
  1265. })
  1266. }).catch(() => {
  1267. this.$message({ type: 'info', message: '已取消应用' })
  1268. })
  1269. },
  1270. // 模板行点击
  1271. tableRowClick(row, column, event) {
  1272. console.log(row, column, event)
  1273. for (let i = 0; i < this.table.list.length; i++) {
  1274. if (this.table.list[i].Edit == true) {
  1275. return false
  1276. }
  1277. }
  1278. if (column.label !== '操作') {
  1279. this.isDetail = true // 点击行显示详情
  1280. this.table2.getdataListParm.parammaps.ftid = row.id
  1281. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1282. this.getList2()
  1283. this.getDownList()
  1284. }
  1285. },
  1286. // -------------------详情-----------------------------
  1287. // 获取是否显示是否锁定牛头数
  1288. getIsLockCount() {
  1289. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1290. console.log(response.data.list)
  1291. if (response.data.list[0].inforvalue == 0) {
  1292. this.lockCount.isLockCount = false
  1293. } else {
  1294. this.lockCount.isLockCount = true
  1295. }
  1296. })
  1297. },
  1298. // 详情
  1299. getList2() {
  1300. this.table2.listLoading = true
  1301. GetDataByName(this.table2.getdataListParm).then(response => {
  1302. console.log('table数据', response.data.list)
  1303. if (response.data.list !== null) {
  1304. for (let i = 0; i < response.data.list.length; i++) {
  1305. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1306. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1307. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1308. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1309. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1310. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1311. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1312. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1313. }
  1314. this.table2.list = response.data.list
  1315. this.table2.pageNum = response.data.pageNum
  1316. this.table2.pageSize = response.data.pageSize
  1317. this.table2.total = response.data.total
  1318. this.rowDrop()
  1319. } else {
  1320. this.table2.list = []
  1321. }
  1322. this.$nextTick(function() {
  1323. console.log(this.$refs)
  1324. console.log(this.$refs.template.clientHeight)
  1325. window.scrollTo({
  1326. 'top': this.$refs.template.clientHeight
  1327. })
  1328. })
  1329. setTimeout(() => {
  1330. this.table2.listLoading = false
  1331. }, 100)
  1332. })
  1333. },
  1334. // 行拖拽
  1335. rowDrop() {
  1336. console.log(1111)
  1337. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1338. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1339. // this.sorTable()
  1340. const that = this
  1341. // Sortable.create(tbody, {
  1342. var sortable = Sortable.create(tbody, {
  1343. disabled: that.dropState,
  1344. onChoose({ newIndex, oldIndex }) {
  1345. if (that.dropState == true) {
  1346. sortable.destroy()
  1347. }
  1348. },
  1349. onEnd({ newIndex, oldIndex }) {
  1350. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1351. that.table2.list.splice(newIndex, 0, currRow)
  1352. console.log('索引', newIndex)
  1353. console.log('拖动数据', currRow)
  1354. console.log('上', that.table2.list[newIndex - 1])
  1355. console.log('下', that.table2.list[newIndex + 1])
  1356. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1357. for (let i = 0; i < that.table2.list.length; i++) {
  1358. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1359. }
  1360. currRow.sort = 0
  1361. currRow.feedgroup = currRow.fname
  1362. console.log('拖动至最上方无值')
  1363. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1364. currRow.sort = that.table2.list[newIndex - 1].sort
  1365. console.log('拖动值顺序等于上值顺序')
  1366. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1367. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1368. currRow.feedgroup = currRow.fname
  1369. console.log('拖动至最下方无值')
  1370. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1371. currRow.sort == that.table2.list[newIndex + 1].sort
  1372. console.log('拖动值顺序等于下值顺序')
  1373. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1374. currRow.sort = that.table2.list[newIndex - 1].sort
  1375. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1376. console.log('拖动至上下顺序一致')
  1377. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1378. console.log('上下')
  1379. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1380. console.log(newIndex)
  1381. for (let i = newIndex; i < that.table2.list.length; i++) {
  1382. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1383. }
  1384. }
  1385. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1386. currRow.feedgroup = currRow.fname
  1387. console.log(that.table2.list[newIndex + 1].sort)
  1388. }
  1389. that.requestParam = {}
  1390. that.requestParam.common = { 'returnmap': '0' }
  1391. that.requestParam.data = []
  1392. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1393. that.requestParam.data[0].children = []
  1394. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1395. id: '@insertSpotList.id',
  1396. pastureid: '@insertSpotList.pastureid',
  1397. sort: '@insertSpotList.sort',
  1398. feedgroup: '@insertSpotList.feedgroup'
  1399. }}
  1400. ExecDataByConfig(that.requestParam).then(response => {
  1401. console.log('顺序切换保存发送参数', that.requestParam)
  1402. if (response.msg === 'fail') {
  1403. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1404. } else {
  1405. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1406. that.getList2()
  1407. }
  1408. })
  1409. }
  1410. })
  1411. console.log(sortable.option('disabled'))
  1412. },
  1413. handleSearch2() {
  1414. console.log('点击了查询')
  1415. this.arrowDown2 = true
  1416. this.arrowUp2 = false
  1417. this.table2.getdataListParm.offset = 1
  1418. this.getList2()
  1419. },
  1420. handleRefresh2() {
  1421. console.log('点击了重置')
  1422. this.table2.getdataListParm.parammaps.fname = ''
  1423. this.table2.getdataListParm.parammaps.feedgroup = ''
  1424. this.table2.getdataListParm.parammaps.fweight = ''
  1425. this.table2.getdataListParm.parammaps.autosecondname = ''
  1426. this.table2.getdataListParm.parammaps.islockcount = '0'
  1427. this.table2.getdataListParm.parammaps.sort = ''
  1428. this.table2.getdataListParm.offset = 1
  1429. this.getList2()
  1430. },
  1431. // 详情新增
  1432. handleCreate2() {
  1433. console.log('点击了详情新增', this.table2.list)
  1434. // 编辑true/不可编辑false
  1435. // 新增操true,编辑false,编辑保存false
  1436. console.log(11)
  1437. for (let i = 0; i < this.table2.list.length; i++) {
  1438. if (this.table2.list[i].Edit === true) {
  1439. console.log(123)
  1440. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1441. return false
  1442. }
  1443. }
  1444. console.log(this.table2.list)
  1445. if (this.table2.list.length == 0) {
  1446. var mysort = 0
  1447. } else {
  1448. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1449. }
  1450. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1451. console.log(this.table2.list)
  1452. },
  1453. changeFname(item, row) {
  1454. console.log(item, row)
  1455. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1456. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1457. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1458. this.table2.temp.preftid = '0'
  1459. } else {
  1460. this.table2.temp.preftid = item
  1461. }
  1462. if (row.sort == '') {
  1463. row.feedgroup = this.table2.temp.fname
  1464. } else {
  1465. if (row.isCreate == true) { // 新增状态下
  1466. for (let i = 1; i < this.table2.list.length; i++) {
  1467. if (this.table2.list[i].sort == row.sort) {
  1468. console.log(this.table2.list[i])
  1469. row.feedgroup = this.table2.list[i].feedgroup
  1470. break
  1471. } else {
  1472. row.feedgroup = this.table2.temp.fname
  1473. }
  1474. }
  1475. } else if (row.isUpdateSave == true) { // 编辑状态下
  1476. var Arr = []
  1477. for (let i = 0; i < this.table2.list.length; i++) {
  1478. Arr.push(this.table2.list[i].sort)
  1479. }
  1480. var Count = 0
  1481. for (let i = 0; i < Arr.length; i++) {
  1482. if (Arr[i] == row.sort) {
  1483. Count++
  1484. }
  1485. }
  1486. for (let i = 0; i < this.table2.list.length; i++) {
  1487. if (Count > 1) {
  1488. row.feedgroup = this.table2.list[i].feedgroup
  1489. console.log(111, this.table2.list[i].feedgroup)
  1490. break
  1491. } else if (Count == 1) {
  1492. row.feedgroup = this.table2.temp.fname
  1493. console.log(222, this.table2.temp.fname)
  1494. }
  1495. }
  1496. }
  1497. }
  1498. },
  1499. bort(row) {
  1500. if (row.isCreate == true) {
  1501. if (row.sort !== '') {
  1502. for (let i = 1; i < this.table2.list.length; i++) {
  1503. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1504. row.feedgroup = this.table2.list[i].feedgroup
  1505. return false
  1506. } else {
  1507. row.feedgroup = row.fname
  1508. }
  1509. }
  1510. } else {
  1511. row.feedgroup = row.fname
  1512. }
  1513. } else if (row.isUpdateSave == true) {
  1514. if (row.sort !== '') {
  1515. for (let i = 0; i < this.table2.list.length; i++) {
  1516. if (this.table2.list[i].sort == row.sort) {
  1517. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1518. if (this.table2.list[i].id !== row.id) {
  1519. row.isGroupDisabled = true
  1520. row.feedgroup = this.table2.list[i].feedgroup
  1521. break
  1522. }
  1523. } else {
  1524. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1525. row.isGroupDisabled = true
  1526. row.feedgroup = row.fname
  1527. }
  1528. }
  1529. } else {
  1530. row.feedgroup = row.fname
  1531. }
  1532. }
  1533. },
  1534. createData2(row) {
  1535. console.log('点击了详情新增保存', row)
  1536. this.table2.temp.pastureid = Cookies.get('pastureid')
  1537. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1538. this.table2.temp.fid = row.fid
  1539. this.table2.temp.fname = this.table2.temp.fname
  1540. this.table2.temp.fweight = row.fweight
  1541. this.table2.temp.islockcount = row.islockcount
  1542. this.table2.temp.sort = row.sort
  1543. this.table2.temp.feedgroup = row.feedgroup
  1544. this.table2.temp.preftid = this.table2.temp.preftid
  1545. this.table2.temp.autosecond = row.autosecond
  1546. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1547. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1548. return false
  1549. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1550. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1551. return false
  1552. } else if (this.table2.temp.fid == '') {
  1553. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1554. return false
  1555. } else if (this.table2.temp.fweight == '') {
  1556. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1557. return false
  1558. } else if (this.table2.temp.autosecond == '') {
  1559. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1560. return false
  1561. }
  1562. if (this.table2.temp.sort !== '') {
  1563. this.table2.temp.sort = this.table2.temp.sort
  1564. } else {
  1565. console.log(this.table2.list.length)
  1566. if (this.table2.list.length == 1) {
  1567. this.table2.temp.sort = 0
  1568. } else {
  1569. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1570. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1571. }
  1572. }
  1573. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1574. if (parseInt(this.table2.temp.preftid) > 0) {
  1575. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1576. return false
  1577. }
  1578. }
  1579. // 校验顺序是否>=0
  1580. var ruleSort = /^\d+$/
  1581. if (!ruleSort.test(this.table2.temp.sort)) {
  1582. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1583. return false
  1584. }
  1585. // 检验重量>0
  1586. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1587. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1588. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1589. return false
  1590. }
  1591. this.isokDisable = true
  1592. setTimeout(() => {
  1593. this.isokDisable = false
  1594. }, 1000)
  1595. this.requestParam.common = { 'returnmap': '0' }
  1596. this.requestParam.data = []
  1597. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1598. pastureid: this.table2.temp.pastureid,
  1599. ftid: this.table2.getdataListParm.parammaps.ftid,
  1600. fid: row.fid,
  1601. fname: this.table2.temp.fname,
  1602. fweight: row.fweight,
  1603. islockcount: row.islockcount,
  1604. sort: row.sort,
  1605. feedgroup: row.feedgroup,
  1606. preftid: this.table2.temp.preftid,
  1607. autosecond: row.autosecond
  1608. }}
  1609. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1610. pastureid: this.table2.temp.pastureid,
  1611. ftid: this.table2.getdataListParm.parammaps.ftid,
  1612. type: this.table2.getdataListParm.parammaps.fttypeid
  1613. }}
  1614. ExecDataByConfig(this.requestParam).then(response => {
  1615. console.log('新增保存发送参数', this.requestParam)
  1616. if (response.msg !== 'fail') {
  1617. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1618. this.getList2()
  1619. } else {
  1620. failproccess(response, this.$notify)
  1621. }
  1622. })
  1623. },
  1624. createCancel2(row) {
  1625. console.log('点击了详情新增取消')
  1626. for (let i = 0; i < this.table2.list.length; i++) {
  1627. if (row.myId === this.table2.list[i].myId) {
  1628. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1629. }
  1630. if (listIndex > -1) {
  1631. this.table2.list.splice(listIndex, 1)
  1632. return
  1633. }
  1634. }
  1635. this.getDialogList()
  1636. },
  1637. // 详情编辑
  1638. handleUpdate2(row) {
  1639. console.log('详情编辑', row)
  1640. this.dropState = true
  1641. row.isGroupDisabled = false
  1642. row.islockcount = String(row.islockcount)
  1643. row.fid = String(row.fid)
  1644. row.autosecond = String(row.autosecond)
  1645. this.table2.temp.fname = row.fname
  1646. this.table2.temp.preftid = row.preftid
  1647. const rowArr = []
  1648. for (let i = 0; i < this.table2.list.length; i++) {
  1649. if (this.table2.list[i].Edit == true) {
  1650. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1651. return false
  1652. }
  1653. rowArr.push(this.table2.list[i].sort)
  1654. }
  1655. var count = 0
  1656. for (let i = 0; i < rowArr.length; i++) {
  1657. if (rowArr[i] == row.sort) {
  1658. count++
  1659. }
  1660. }
  1661. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1662. if (count == 1) {
  1663. // 饲料组编辑false,不可编辑true
  1664. row.groupEdit = false
  1665. row.groupNoEdit = true
  1666. // 编辑true,不可编辑false
  1667. row.Edit = true
  1668. row.NoEdit = false
  1669. // 新增false,编辑false,编辑保存true
  1670. row.isCreate = false
  1671. row.isUpdate = false
  1672. row.isUpdateSave = true
  1673. } else if (count > 1) {
  1674. // 饲料组编辑true,不可编辑false
  1675. row.groupEdit = true
  1676. row.groupNoEdit = false
  1677. console.log(222)
  1678. // 编辑true,不可编辑false
  1679. row.Edit = true
  1680. row.NoEdit = false
  1681. // 新增false,编辑false,编辑保存true
  1682. row.isCreate = false
  1683. row.isUpdate = false
  1684. row.isUpdateSave = true
  1685. return false
  1686. }
  1687. },
  1688. updateData2(row) {
  1689. console.log('点击了详情编辑保存111', row)
  1690. this.isokDisable = true
  1691. setTimeout(() => {
  1692. this.isokDisable = false
  1693. }, 1000)
  1694. this.table2.temp.pastureid = row.pastureid
  1695. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1696. this.table2.temp.fid = row.fid
  1697. this.table2.temp.fname = this.table2.temp.fname
  1698. this.table2.temp.fweight = row.fweight
  1699. this.table2.temp.islockcount = row.islockcount
  1700. this.table2.temp.sort = row.sort
  1701. this.table2.temp.feedgroup = row.feedgroup
  1702. this.table2.temp.preftid = this.table2.temp.preftid
  1703. this.table2.temp.autosecond = row.autosecond
  1704. this.table2.temp.id = row.id
  1705. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1706. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1707. return false
  1708. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1709. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1710. return false
  1711. } else if (this.table2.temp.fid == '') {
  1712. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1713. return false
  1714. } else if (this.table2.temp.fweight == '') {
  1715. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1716. return false
  1717. } else if (this.table2.temp.autosecond == '') {
  1718. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1719. return false
  1720. }
  1721. if (this.table2.temp.sort !== '') {
  1722. this.table2.temp.sort = this.table2.temp.sort
  1723. } else {
  1724. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1725. }
  1726. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1727. if (parseInt(this.table2.temp.preftid) > 0) {
  1728. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1729. return false
  1730. }
  1731. }
  1732. // 校验顺序是否>=0
  1733. var ruleSort = /^\d+$/
  1734. if (!ruleSort.test(this.table2.temp.sort)) {
  1735. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1736. return false
  1737. }
  1738. // 检验重量>0
  1739. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1740. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1741. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1742. return false
  1743. }
  1744. this.requestParam.common = { 'returnmap': '0' }
  1745. this.requestParam.data = []
  1746. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1747. pastureid: row.pastureid,
  1748. ftid: this.table2.getdataListParm.parammaps.ftid,
  1749. fid: row.fid,
  1750. fname: this.table2.temp.fname,
  1751. fweight: row.fweight,
  1752. islockcount: row.islockcount,
  1753. sort: row.sort,
  1754. feedgroup: row.feedgroup,
  1755. preftid: this.table2.temp.preftid,
  1756. autosecond: row.autosecond,
  1757. id: row.id
  1758. }}
  1759. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1760. pastureid: row.pastureid,
  1761. ftid: this.table2.getdataListParm.parammaps.ftid,
  1762. type: this.table2.getdataListParm.parammaps.fttypeid
  1763. }}
  1764. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1765. pastureid: row.pastureid,
  1766. ftid: this.table2.getdataListParm.parammaps.ftid,
  1767. sort: row.sort,
  1768. feedgroup: row.feedgroup
  1769. }}
  1770. ExecDataByConfig(this.requestParam).then(response => {
  1771. console.log('新增保存发送参数', this.requestParam)
  1772. if (response.msg !== 'fail') {
  1773. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1774. this.getList2()
  1775. this.dropState = false
  1776. } else {
  1777. failproccess(response, this.$notify)
  1778. }
  1779. })
  1780. },
  1781. updateCancel2(row) {
  1782. console.log('点击了详情编辑取消')
  1783. // 饲料组编辑false,不可编辑true
  1784. row.groupEdit = false
  1785. row.groupNoEdit = true
  1786. // 编辑false,不可编辑true
  1787. row.Edit = false
  1788. row.NoEdit = true
  1789. // 新增false,编辑true,编辑保存false
  1790. row.isCreate = false
  1791. row.isUpdate = true
  1792. row.isUpdateSave = false
  1793. this.getList2()
  1794. this.dropState = false
  1795. },
  1796. // 详情删除
  1797. handleRowDelete2(row) {
  1798. console.log('点击了行内删除')
  1799. MessageBox.confirm('是否确认删除此信息?', {
  1800. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1801. }).then(() => {
  1802. this.requestParam.common = { 'returnmap': '0' }
  1803. this.requestParam.data = []
  1804. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1805. pastureid: row.pastureid,
  1806. id: row.id
  1807. }}
  1808. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1809. pastureid: row.pastureid,
  1810. ftid: this.table2.getdataListParm.parammaps.ftid,
  1811. type: this.table2.getdataListParm.parammaps.fttypeid
  1812. }}
  1813. ExecDataByConfig(this.requestParam).then(response => {
  1814. console.log('新增保存发送参数', this.requestParam)
  1815. if (response.msg === 'fail') {
  1816. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1817. } else {
  1818. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1819. this.getList2()
  1820. }
  1821. })
  1822. }).catch(() => {
  1823. this.$message({ type: 'info', message: '已取消删除' })
  1824. })
  1825. },
  1826. handleSelectionChange2(val) {
  1827. console.log('勾选数据', val)
  1828. this.selectList2 = val
  1829. },
  1830. handleDelete2() {
  1831. console.log('点击了删除')
  1832. if (this.selectList2.length == 0) {
  1833. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1834. } else {
  1835. MessageBox.confirm('是否确认删除此信息?', {
  1836. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1837. }).then(() => {
  1838. console.log(this.selectList)
  1839. this.requestParam.common = { 'returnmap': '0' }
  1840. this.requestParam.data = []
  1841. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1842. this.requestParam.data[0].children = []
  1843. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1844. id: '@insertSpotList.id',
  1845. pastureid: '@insertSpotList.pastureid'
  1846. }}
  1847. ExecDataByConfig(this.requestParam).then(response => {
  1848. console.log('删除保存发送参数', this.requestParam)
  1849. if (response.msg === 'fail') {
  1850. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1851. } else {
  1852. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1853. this.getList2()
  1854. }
  1855. })
  1856. })
  1857. }
  1858. },
  1859. // 拆分预混料
  1860. handleSplitPremix(row) {
  1861. console.log('点击了拆分预混料')
  1862. MessageBox.confirm('是否确认拆分当前预混料?', {
  1863. confirmButtonText: '确认',
  1864. cancelButtonText: '取消',
  1865. type: 'warning'
  1866. }).then(() => {
  1867. this.requestParam.name = 'splitFTpre'
  1868. this.requestParam.parammaps = {}
  1869. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1870. this.requestParam.parammaps.preftid = row.preftid
  1871. this.requestParam.parammaps.ftdid = row.id
  1872. this.requestParam.parammaps.pastureid = row.pastureid
  1873. this.requestParam.parammaps.feedgroup = row.feedgroup
  1874. this.requestParam.parammaps.sort = row.sort
  1875. this.requestParam.parammaps.fweight = row.fweight
  1876. PostDataByName(this.requestParam).then(response => {
  1877. if (response.msg === 'fail') {
  1878. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1879. } else {
  1880. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1881. this.getList2()
  1882. }
  1883. })
  1884. }).catch(() => {
  1885. this.$message({
  1886. type: 'info',
  1887. message: '已取消删除'
  1888. })
  1889. })
  1890. },
  1891. // 合成预混料
  1892. handleSyntheticPremix() {
  1893. console.log('点击了合成预混料', this.selectList2)
  1894. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1895. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  1896. return false
  1897. } else {
  1898. if (this.selectList2.length > 1) {
  1899. for (let i = 0; i < this.selectList2.length; i++) {
  1900. if (parseInt(this.selectList2[i].preftid) > 0) {
  1901. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  1902. return false
  1903. }
  1904. }
  1905. if (this.selectList2[0].splitftpreid !== undefined) {
  1906. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  1907. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  1908. GetDataByName(this.detail.getdataListParm).then(response => {
  1909. if (response.data.list !== null) { // 不为空时得到比对数据
  1910. this.detail.list3 = response.data.list
  1911. const sortList = [] // 声明排序数组
  1912. var fweightSum = 0 // 总重量
  1913. for (let i = 0; i < this.selectList2.length; i++) {
  1914. const obj = {}
  1915. obj.fid = this.selectList2[i].fid
  1916. obj.fweight = this.selectList2[i].fweight
  1917. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  1918. sortList.push(obj)
  1919. }
  1920. // 排序
  1921. sortList.sort(function(a, b) {
  1922. return a.fid.localeCompare(b.fid)
  1923. })
  1924. var a = 0
  1925. if (this.detail.list3.length == sortList.length) {
  1926. for (let i = 0; i < this.detail.list3.length; i++) {
  1927. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  1928. a++
  1929. }
  1930. }
  1931. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  1932. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  1933. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  1934. GetDataByName(this.detail.getdataListParm2).then(response => {
  1935. if (response.data.list !== null) {
  1936. this.detail.dialogStatus = 'SyntheticPremix'
  1937. this.detail.dialogFormVisible = true
  1938. this.detail.list = this.selectList2
  1939. this.detail.list2 = response.data.list
  1940. this.detail.disabled = true
  1941. setTimeout(() => {
  1942. this.detail.listLoading = false
  1943. }, 100)
  1944. } else {
  1945. this.detail.list2 = []
  1946. }
  1947. })
  1948. } else {
  1949. this.detail.dialogStatus = 'SyntheticPremix'
  1950. this.detail.dialogFormVisible = true
  1951. this.detail.list = this.selectList2
  1952. this.detail.disabled = false
  1953. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1954. setTimeout(() => {
  1955. this.detail.listLoading = false
  1956. }, 100)
  1957. }
  1958. } else {
  1959. this.detail.dialogStatus = 'SyntheticPremix'
  1960. this.detail.dialogFormVisible = true
  1961. this.detail.list = this.selectList2
  1962. this.detail.disabled = false
  1963. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1964. setTimeout(() => {
  1965. this.detail.listLoading = false
  1966. }, 100)
  1967. }
  1968. } else {
  1969. this.detail.list3 = []
  1970. this.detail.dialogStatus = 'SyntheticPremix'
  1971. this.detail.dialogFormVisible = true
  1972. this.detail.list = this.selectList2
  1973. this.detail.disabled = false
  1974. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1975. setTimeout(() => {
  1976. this.detail.listLoading = false
  1977. }, 100)
  1978. }
  1979. })
  1980. } else {
  1981. this.detail.dialogStatus = 'SyntheticPremix'
  1982. this.detail.dialogFormVisible = true
  1983. this.detail.list = this.selectList2
  1984. this.detail.disabled = false
  1985. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1986. setTimeout(() => {
  1987. this.detail.listLoading = false
  1988. }, 100)
  1989. }
  1990. } else {
  1991. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  1992. return false
  1993. }
  1994. }
  1995. },
  1996. // 畜生类别
  1997. changeLivestockType2(item) {
  1998. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1999. },
  2000. syntheticPremixData() {
  2001. console.log('点击了合成预混料确认')
  2002. if (this.detail.disabled == true) { // 原预混料
  2003. let sumFweight = 0
  2004. for (let i = 0; i < this.detail.list.length; i++) {
  2005. sumFweight += parseFloat(this.detail.list[i].fweight)
  2006. }
  2007. sumFweight = sumFweight.toFixed(2)
  2008. this.isokDisable = true
  2009. setTimeout(() => {
  2010. this.isokDisable = false
  2011. }, 1000)
  2012. this.requestParam.common = { 'returnmap': '0' }
  2013. this.requestParam.data = []
  2014. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2015. this.requestParam.data[0].children = []
  2016. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2017. pastureid: '@insertSpotList.pastureid',
  2018. id: '@insertSpotList.id'
  2019. }}
  2020. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2021. this.requestParam.data[1].children = []
  2022. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2023. pastureid: Cookies.get('pastureid'),
  2024. ftid: this.table2.getdataListParm.parammaps.ftid,
  2025. fid: this.detail.list2[0].id,
  2026. fname: '@insertSpotList2.tname',
  2027. fweight: sumFweight,
  2028. islockcount: '0',
  2029. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2030. feedgroup: '@insertSpotList2.tname',
  2031. preftid: this.detail.list2[0].id,
  2032. autosecond: this.detail.list[0].autosecond
  2033. }}
  2034. ExecDataByConfig(this.requestParam).then(response => {
  2035. console.log('合成预混料保存发送参数', this.requestParam)
  2036. if (response.msg === 'fail') {
  2037. const tname = new RegExp("key 'tname'")
  2038. if (tname.test(response.data)) {
  2039. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2040. } else {
  2041. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2042. }
  2043. } else {
  2044. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2045. this.detail.dialogFormVisible = false
  2046. this.getList()
  2047. this.getList2()
  2048. this.getDownList()
  2049. }
  2050. })
  2051. } else { // 现生成预混料
  2052. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2053. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2054. return false
  2055. } else if (this.detail.list2[0].tname == '') {
  2056. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2057. return false
  2058. } else if (this.detail.list2[0].ccid == '') {
  2059. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2060. return false
  2061. }
  2062. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2063. if (pattern.test(this.detail.list2[0].tname)) {
  2064. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2065. return false
  2066. }
  2067. let sumFweight = 0
  2068. for (let i = 0; i < this.detail.list.length; i++) {
  2069. sumFweight += parseFloat(this.detail.list[i].fweight)
  2070. }
  2071. sumFweight = sumFweight.toFixed(2)
  2072. console.log(sumFweight)
  2073. this.isokDisable = true
  2074. setTimeout(() => {
  2075. this.isokDisable = false
  2076. }, 1000)
  2077. if (this.detail.list2[0].tcolor == null) {
  2078. this.detail.list2[0].tcolor = '#CCCCCC'
  2079. }
  2080. this.requestParam.common = { 'returnmap': '0' }
  2081. this.requestParam.data = []
  2082. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2083. pastureid: Cookies.get('pastureid'),
  2084. tcode: this.detail.list2[0].tcode,
  2085. tname: this.detail.list2[0].tname,
  2086. tcolor: this.detail.list2[0].tcolor,
  2087. ccid: this.detail.list2[0].ccid,
  2088. ccname: this.detail.list2[0].ccname,
  2089. fttype: this.detail.list2[0].fttype,
  2090. fttypeid: this.detail.list2[0].fttypeid,
  2091. source: this.detail.list2[0].source,
  2092. remark: this.detail.list2[0].remark,
  2093. enable: this.detail.list2[0].enable
  2094. }}
  2095. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2096. this.requestParam.data[1].children = []
  2097. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2098. pastureid: '@insertSpotList.pastureid',
  2099. ftid: '@insertFT.LastInsertId',
  2100. fid: '@insertSpotList.fid',
  2101. fname: '@insertSpotList.fname',
  2102. fweight: '@insertSpotList.fweight',
  2103. islockcount: '@insertSpotList.islockcount',
  2104. sort: '@insertSpotList.sort',
  2105. feedgroup: '@insertSpotList.feedgroup',
  2106. preftid: '@insertSpotList.preftid',
  2107. autosecond: '@insertSpotList.autosecond'
  2108. }}
  2109. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2110. pastureid: '@insertSpotList.pastureid',
  2111. id: '@insertSpotList.id'
  2112. }}
  2113. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2114. this.requestParam.data[2].children = []
  2115. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2116. pastureid: Cookies.get('pastureid'),
  2117. ftid: this.table2.getdataListParm.parammaps.ftid,
  2118. fid: '@insertFT.LastInsertId',
  2119. fname: '@insertSpotList2.tname',
  2120. fweight: sumFweight,
  2121. islockcount: '0',
  2122. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2123. feedgroup: '@insertSpotList2.tname',
  2124. preftid: '@insertFT.LastInsertId',
  2125. autosecond: this.detail.list[0].autosecond
  2126. }}
  2127. ExecDataByConfig(this.requestParam).then(response => {
  2128. console.log('合成预混料保存发送参数', this.requestParam)
  2129. if (response.msg === 'fail') {
  2130. const tname = new RegExp("key 'tname'")
  2131. if (tname.test(response.data)) {
  2132. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2133. } else {
  2134. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2135. }
  2136. } else {
  2137. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2138. this.detail.dialogFormVisible = false
  2139. this.getList()
  2140. this.getList2()
  2141. this.getDownList()
  2142. }
  2143. })
  2144. }
  2145. }
  2146. }
  2147. }
  2148. </script>
  2149. <style lang="scss" scoped>
  2150. .search{margin-top:10px;}
  2151. .table{margin-top:10px;}
  2152. .table2{margin-top:10px;}
  2153. $width:350px;
  2154. $left:325px;
  2155. .selectInput{
  2156. position: relative;
  2157. display: inline-block;
  2158. .Input{width: $width;position: relative;}
  2159. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2160. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2161. .selectUl{
  2162. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2163. li{
  2164. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2165. a{float:left;width: 80px;}
  2166. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2167. }
  2168. }
  2169. }
  2170. .template{
  2171. background: #fff;
  2172. position: relative;
  2173. .recipeTemplate{
  2174. width: 72px;
  2175. height: 70px;
  2176. position: absolute;
  2177. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2178. right: 0;
  2179. top: 0;
  2180. margin: 0;
  2181. }
  2182. }
  2183. .detail{
  2184. background: #fff;
  2185. position: relative;
  2186. .recipeDetail{
  2187. width: 72px;
  2188. height: 70px;
  2189. position: absolute;
  2190. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2191. right: 0;
  2192. top: 0;
  2193. margin: 0;
  2194. }
  2195. }
  2196. .templateDialog{
  2197. background: #fff;
  2198. position: relative;
  2199. .recipeTemplate{
  2200. width: 72px;
  2201. height: 70px;
  2202. position: absolute;
  2203. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2204. right: 0;
  2205. top: 0;
  2206. margin: 0;
  2207. }
  2208. }
  2209. .detailDialog{
  2210. background: #fff;
  2211. position: relative;
  2212. .recipeDetail{
  2213. width: 72px;
  2214. height: 70px;
  2215. position: absolute;
  2216. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2217. right: 0;
  2218. top: 0;
  2219. margin: 0;
  2220. }
  2221. }
  2222. </style>